\documentclass[12pt]{article}
\usepackage{times}
\usepackage{graphicx}
\usepackage{sidecap}
\usepackage{wrapfig}
\usepackage{fancyhdr}
\pagestyle{fancy}
\renewcommand{\baselinestretch}{1.2}
\newenvironment{mylisting}
{\begin{list}{}{\setlength{\leftmargin}{1em}}\item\scriptsize\bfseries}
{\end{list}}
\newenvironment{mylisting2}
{\begin{list}{}{\setlength{\leftmargin}{1em}}\item\scriptsize\bfseries}
{\end{list}}

%%% This file is Open Content

\begin{document}
	\textbf{{\Huge Beastlands}}
{\center{Dec 29, 2011, 
	Johan Ceuppens, Theo D'Hondt - Vrije Universiteit Brussel}}
\\
{\large{\textbf{\center Abstract}}}
\\
\\
\section{\large Introduction}



\begin{mylisting}
\begin{verbatim}

	

# Copyright (C) Johan Ceuppens 2010
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


import pygame
from pygame.locals import *
from gameobject import *
from stateimagelibrary import *
import random
from time import *
from venomspit import *

class ArchGohma(Gameobject):
    "Arch Gohma enemy"
    def __init__(self,xx,yy):
	Gameobject.__init__(self, xx, yy)
        self.w = 86
        self.h = 63 
	self.stimlibleft = Stateimagelibrary()	
	self.stimlibright = Stateimagelibrary()	
        image = pygame.image.load('./pics/archgohma1-86x63.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/archgohma1-86x63.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/archgohma1-86x63.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/archgohma1-86x63.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/archgohma1-86x63.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/archgohma1-86x63.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/archgohma2-86x63.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/archgohma2-86x63.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/archgohma2-86x63.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/archgohma2-86x63.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/archgohma2-86x63.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/archgohma2-86x63.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/archgohma3-86x63.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/archgohma3-86x63.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/archgohma3-86x63.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/archgohma3-86x63.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/archgohma3-86x63.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/archgohma3-86x63.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibleft.addpicture(image)
        image = pygame.image.load('./pics/archgohma2-86x63.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/archgohma2-86x63.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/archgohma2-86x63.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/archgohma2-86x63.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/archgohma2-86x63.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/archgohma2-86x63.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibleft.addpicture(image)
        image = pygame.image.load('./pics/archgohma1-86x63.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibright.addpicture(image)
	image = pygame.image.load('./pics/archgohma1-86x63.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibright.addpicture(image)
	image = pygame.image.load('./pics/archgohma1-86x63.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibright.addpicture(image)
	image = pygame.image.load('./pics/archgohma1-86x63.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibright.addpicture(image)
	image = pygame.image.load('./pics/archgohma1-86x63.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibright.addpicture(image)
	image = pygame.image.load('./pics/archgohma1-86x63.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibright.addpicture(image)
	image = pygame.image.load('./pics/archgohma2-86x63.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibright.addpicture(image)
	image = pygame.image.load('./pics/archgohma2-86x63.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibright.addpicture(image)
	image = pygame.image.load('./pics/archgohma2-86x63.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibright.addpicture(image)
	image = pygame.image.load('./pics/archgohma2-86x63.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibright.addpicture(image)
	image = pygame.image.load('./pics/archgohma2-86x63.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibright.addpicture(image)
	image = pygame.image.load('./pics/archgohma2-86x63.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibright.addpicture(image)
	image = pygame.image.load('./pics/archgohma2-86x63.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibright.addpicture(image)
	image = pygame.image.load('./pics/archgohma2-86x63.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibright.addpicture(image)
	image = pygame.image.load('./pics/archgohma3-86x63.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibright.addpicture(image)
	image = pygame.image.load('./pics/archgohma3-86x63.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibright.addpicture(image)
	image = pygame.image.load('./pics/archgohma3-86x63.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibright.addpicture(image)
	image = pygame.image.load('./pics/archgohma3-86x63.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibright.addpicture(image)
	image = pygame.image.load('./pics/archgohma3-86x63.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibright.addpicture(image)
	image = pygame.image.load('./pics/archgohma3-86x63.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibright.addpicture(image)
	image = pygame.image.load('./pics/archgohma3-86x63.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibright.addpicture(image)
	image = pygame.image.load('./pics/archgohma3-86x63.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibright.addpicture(image)
        image = pygame.image.load('./pics/archgohma2-86x63.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibright.addpicture(image)
	image = pygame.image.load('./pics/archgohma2-86x63.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibright.addpicture(image)
	image = pygame.image.load('./pics/archgohma2-86x63.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibright.addpicture(image)
	image = pygame.image.load('./pics/archgohma2-86x63.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibright.addpicture(image)
	image = pygame.image.load('./pics/archgohma2-86x63.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibright.addpicture(image)
	image = pygame.image.load('./pics/archgohma2-86x63.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibright.addpicture(image)
	image = pygame.image.load('./pics/archgohma2-86x63.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibright.addpicture(image)
	image = pygame.image.load('./pics/archgohma2-86x63.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibright.addpicture(image)
	self.direction = "left"

    def draw(self, screen, room):
	if (self.direction == "left"):
            self.stimlibleft.draw(screen, self.x+room.relativex,self.y+room.relativey)
	elif (self.direction == "right"):
            self.stimlibright.draw(screen, self.x+room.relativex,self.y+room.relativey)
	    
	     
    def update(self,room):
        sleep(.01) # FIX darkknight sleep
	if (random.randint(0,100) == 0 and self.direction == "left"):
	   self.direction = "right"
	elif (random.randint(0,100) == 0 and self.direction == "right"):
	   self.direction = "left"

	if (not self.collideobjectX(room)): 
	    if (self.direction == "left"):
	        self.x +=2
	        self.direction = "right" 
	    elif (self.direction == "right"):
	        self.x -=2
	        self.direction = "left"


	if (self.direction == "left"):
	        self.x -=1 
	elif (self.direction == "right"):
	        self.x +=1

        if random.randint(0,300) == 0:
            room.gameobjects.append(Venomspit(self.x+self.w/2,self.y+self.h))

    def collide(self, room, player):
	if (player.x > self.x+room.relativex  and 
	player.x < self.x+room.relativex+self.w and 
	player.y > self.y+room.relativey and 
	player.y < self.y+room.relativey + self.h):
	    print "collision with ArchGohma!"
	    if player.hit():
		return 1 
	    else:
	    	return 2 
	else:
	    return 0

		 

# Copyright (C) Johan Ceuppens 2010
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


import pygame
from pygame.locals import *
from gameobject import *
from stateimagelibrary import *
import random
from time import *

class Assassin(Gameobject):
    "Assassin NPC"
    def __init__(self,xx,yy):
	Gameobject.__init__(self, xx, yy)
        self.w = 48
        self.h = 48 
	self.stimlibdown = Stateimagelibrary()	
	self.stimlibup = Stateimagelibrary()	
        image = pygame.image.load('./pics/assassin1-48x48.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibdown.addpicture(image)	
        image = pygame.image.load('./pics/assassin1-48x48.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibdown.addpicture(image)
	image = pygame.image.load('./pics/assassin1-48x48.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibdown.addpicture(image)
	image = pygame.image.load('./pics/assassin1-48x48.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibdown.addpicture(image)

	image = pygame.image.load('./pics/assassin2-48x48.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibdown.addpicture(image)	
        image = pygame.image.load('./pics/assassin2-48x48.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibdown.addpicture(image)
	image = pygame.image.load('./pics/assassin2-48x48.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibdown.addpicture(image)
	image = pygame.image.load('./pics/assassin2-48x48.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibdown.addpicture(image)

        image = pygame.image.load('./pics/assassin3-48x48.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibdown.addpicture(image)	
        image = pygame.image.load('./pics/assassin3-48x48.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibdown.addpicture(image)
	image = pygame.image.load('./pics/assassin3-48x48.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibdown.addpicture(image)
	image = pygame.image.load('./pics/assassin3-48x48.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibdown.addpicture(image)

        image = pygame.image.load('./pics/assassin2-48x48.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibdown.addpicture(image)	
        image = pygame.image.load('./pics/assassin2-48x48.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibdown.addpicture(image)
	image = pygame.image.load('./pics/assassin2-48x48.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibdown.addpicture(image)
	image = pygame.image.load('./pics/assassin2-48x48.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibdown.addpicture(image)

        image = pygame.image.load('./pics/assassinup1-48x48.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibup.addpicture(image)
	image = pygame.image.load('./pics/assassinup1-48x48.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibup.addpicture(image)
	image = pygame.image.load('./pics/assassinup1-48x48.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibup.addpicture(image)
	image = pygame.image.load('./pics/assassinup1-48x48.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibup.addpicture(image)

	image = pygame.image.load('./pics/assassinup2-48x48.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibup.addpicture(image)
	image = pygame.image.load('./pics/assassinup2-48x48.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibup.addpicture(image)
	image = pygame.image.load('./pics/assassinup2-48x48.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibup.addpicture(image)
	image = pygame.image.load('./pics/assassinup2-48x48.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibup.addpicture(image)

	image = pygame.image.load('./pics/assassinup3-48x48.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibup.addpicture(image)
	image = pygame.image.load('./pics/assassinup3-48x48.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibup.addpicture(image)
	image = pygame.image.load('./pics/assassinup3-48x48.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibup.addpicture(image)
	image = pygame.image.load('./pics/assassinup3-48x48.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibup.addpicture(image)
        	
        image = pygame.image.load('./pics/assassinup2-48x48.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibup.addpicture(image)
	image = pygame.image.load('./pics/assassinup2-48x48.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibup.addpicture(image)
	image = pygame.image.load('./pics/assassinup2-48x48.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibup.addpicture(image)
	image = pygame.image.load('./pics/assassinup2-48x48.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibup.addpicture(image)

	self.talkcounter = 0
	self.direction = "down"

    def draw(self, screen, room):
	if (self.direction == "down"):
            self.stimlibdown.draw(screen, self.x+room.relativex,self.y+room.relativey)
	elif (self.direction == "up"):
            self.stimlibup.draw(screen, self.x+room.relativex,self.y+room.relativey)
	    
	     
    def update(self,room):
        sleep(.04) # FIX assassin sleep
	
	if (not self.collideobjectY(room)): 
	    if (self.direction == "down"):
	        self.y -=2
	        self.direction = "up" 
	    elif (self.direction == "up"):
	        self.y +=2
	        self.direction = "down"

	if (self.direction == "up"):
	        self.y -=1 
	elif (self.direction == "down"):
	        self.y +=1

    def collide(self, room, player):
        
	if (player.x > self.x+room.relativex  and 
	player.x < self.x+room.relativex+self.w and 
	player.y > self.y+room.relativey and 
	player.y < self.y+room.relativey + self.h):
	    print "collision with assassin!"
	    return 2 
	else:
	    return 0 ## for game self.talker

		 
    def talk(self, screen,font):
        if self.talkcounter == 0:
            return
        
        if self.talkcounter > 2:
                self.talkcounter = 0
                return 
        talkover = 0
        while talkover == 0:
            pygame.display.update()
            if self.talkcounter == 1:
                screen.blit(font.render("I protect the archmage.", 8, (255,255,255)), (100,100))
            elif self.talkcounter == 2:
                screen.blit(font.render("He is my liege.", 8, (255,255,255)), (100,100))
            for event in pygame.event.get():
                if event.type == QUIT:
                    return
                elif event.type == KEYDOWN:
                    if event.key == K_z:
                        talkover = 1
                        self.talkcounter += 1
                

# Copyright (C) Johan Ceuppens 2010
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


import pygame
from pygame.locals import *
from gameobject import *
from stateimagelibrary import *
import random
from rng import *
from time import *

class BeholderBat(Gameobject):
    "Beholder"
    def __init__(self,xx,yy):
	Gameobject.__init__(self, xx, yy)
        self.w = 48
        self.h = 48

        self.hitpoints = 3
        
	self.stimlib = Stateimagelibrary()	
        image = pygame.image.load('./pics/beholderbat1-48x48.bmp').convert()
        image.set_colorkey((255,0,0)) 
	self.stimlib.addpicture(image)	
        image = pygame.image.load('./pics/beholderbat2-48x48.bmp').convert()
        image.set_colorkey((255,0,0)) 
	self.stimlib.addpicture(image)

	self.talkcounter = 0
	self.direction = "left"

    def draw(self, screen, room):
        self.stimlib.draw(screen, self.x+room.relativex,self.y+room.relativey)
	    
	     
    def update(self,room,player):
        sleep(.04) # FIX goblin sleep
	if room.collidewithenemy(self):
	    if (self.direction == "right"):
	        self.x -=6
	        self.direction = "left" 
	    elif (self.direction == "left"):
	        self.x +=6
	        self.direction = "right"
	    elif (self.direction == "down"):
	        self.y -=6
	        self.direction = "up" 
	    elif (self.direction == "up"):
	        self.y +=6
	        self.direction = "down"

	if player.x+28-room.relativex < self.x:
		self.x -= 3
		self.direction = "left"
	if player.x-28-room.relativex > self.x:
		self.direction = "right"
		self.x += 3	
	if player.y+10-room.relativey < self.y:
		self.direction = "up"
		self.y -= 3
	if player.y-10-room.relativey > self.y:
		self.direction = "down"
		self.y += 3

    def collide(self, room, player):
        # FIX BUG
        #print 'gameobject x=%d y=%d player x=%d y=%d' % (self.x,self.y,player.x-room.relativex,player.y-room.relativey)
	if (player.x-room.relativex > self.x-self.w  and 
	player.x-room.relativex < self.x+self.w+self.w and 
	player.y-room.relativey > self.y-self.h and 
	player.y-room.relativey < self.y + self.h +self.h):
	    #print "collision with Game Object!"
	    return 1 
	else:
	    return 0 ## for game self.talker


    def fight(self,room,player):
        self.fightcounter = 1
        o = player.collidewithenemyweapon(room,self)
        if o:
            player.hitwithenemyweapon(RNG().rollbeholderbatzap())

# Copyright (C) Johan Ceuppens 2010
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


import pygame
from pygame.locals import *
from gameobject import *
from stateimagelibrary import *
import random
from rng import *
from time import *

class BeholderGlassSummoner(Gameobject):
    "Beholder"
    def __init__(self,xx,yy):
	Gameobject.__init__(self, xx, yy)
        self.w = 60 
        self.h = 48

        self.hitpoints = 10
        
	self.stimlib = Stateimagelibrary()	
        image = pygame.image.load('./pics/beholder1-48x48.bmp').convert()
        image.set_colorkey((255,0,0)) 
	self.stimlib.addpicture(image)	
        image = pygame.image.load('./pics/beholder2-48x48.bmp').convert()
        image.set_colorkey((255,0,0)) 
	self.stimlib.addpicture(image)
        image = pygame.image.load('./pics/beholder3-48x48.bmp').convert()
        image.set_colorkey((255,0,0)) 
	self.stimlib.addpicture(image)	
        image = pygame.image.load('./pics/beholder4-48x48.bmp').convert()
        image.set_colorkey((255,0,0)) 
	self.stimlib.addpicture(image)
        image = pygame.image.load('./pics/beholder5-48x48.bmp').convert()
        image.set_colorkey((255,0,0)) 
	self.stimlib.addpicture(image)	
        image = pygame.image.load('./pics/beholder6-48x48.bmp').convert()
        image.set_colorkey((255,0,0)) 
	self.stimlib.addpicture(image)
        image = pygame.image.load('./pics/beholder7-48x48.bmp').convert()
        image.set_colorkey((255,0,0)) 
	self.stimlib.addpicture(image)	
        image = pygame.image.load('./pics/beholder8-48x48.bmp').convert()
        image.set_colorkey((255,0,0)) 
	self.stimlib.addpicture(image)
        image = pygame.image.load('./pics/beholder9-48x48.bmp').convert()
        image.set_colorkey((255,0,0)) 
	self.stimlib.addpicture(image)
        image = pygame.image.load('./pics/beholder10-48x48.bmp').convert()
        image.set_colorkey((255,0,0)) 
	self.stimlib.addpicture(image)
        image = pygame.image.load('./pics/beholder11-48x48.bmp').convert()
        image.set_colorkey((255,0,0)) 
	self.stimlib.addpicture(image)
        image = pygame.image.load('./pics/beholder12-48x48.bmp').convert()
        image.set_colorkey((255,0,0)) 
	self.stimlib.addpicture(image)
        image = pygame.image.load('./pics/beholder13-48x48.bmp').convert()
        image.set_colorkey((255,0,0)) 
	self.stimlib.addpicture(image)
        image = pygame.image.load('./pics/beholder14-48x48.bmp').convert()
        image.set_colorkey((255,0,0)) 
	self.stimlib.addpicture(image)

	self.talkcounter = 0
	self.direction = "left"

    def draw(self, screen, room):
        self.stimlib.draw(screen, self.x+room.relativex,self.y+room.relativey)
	    
	     
    def update(self,room,player):
        sleep(.04) # FIX goblin sleep
	if room.collidewithenemy(self):
	    if (self.direction == "right"):
	        self.x -=6
	        self.direction = "left" 
	    elif (self.direction == "left"):
	        self.x +=6
	        self.direction = "right"
	    elif (self.direction == "down"):
	        self.y -=6
	        self.direction = "up" 
	    elif (self.direction == "up"):
	        self.y +=6
	        self.direction = "down"

	if player.x+28-room.relativex < self.x:
		self.x -= 3
		self.direction = "left"
	if player.x-28-room.relativex > self.x:
		self.direction = "right"
		self.x += 3	
	if player.y+10-room.relativey < self.y:
		self.direction = "up"
		self.y -= 3
	if player.y-10-room.relativey > self.y:
		self.direction = "down"
		self.y += 3

    def collide(self, room, player):
        # FIX BUG
        #print 'gameobject x=%d y=%d player x=%d y=%d' % (self.x,self.y,player.x-room.relativex,player.y-room.relativey)
	if (player.x-room.relativex > self.x-self.w  and 
	player.x-room.relativex < self.x+self.w+self.w and 
	player.y-room.relativey > self.y-self.h and 
	player.y-room.relativey < self.y + self.h +self.h):
	    #print "collision with Game Object!"
	    return 1 
	else:
	    return 0 ## for game self.talker


    def fight(self,room,player):
        self.fightcounter = 1
        o = player.collideiwthenemyweapon(room,self)
        if o:
            player.hitwithenemyweapon(RNG().rollbeholderzap())

# Copyright (C) Johan Ceuppens 2010
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


import pygame
from pygame.locals import *
from gameobject import *
from stateimagelibrary import *
import random
from rng import *
from time import *

class Beholder(Gameobject):
    "Beholder"
    def __init__(self,xx,yy):
	Gameobject.__init__(self, xx, yy)
        self.w = 48
        self.h = 48

        self.hitpoints = 10
        
	self.stimlib = Stateimagelibrary()	
	self.stimlibup = Stateimagelibrary()	
        image = pygame.image.load('./pics/beholder1-48x48.bmp').convert()
        image.set_colorkey((255,0,0)) 
	self.stimlib.addpicture(image)	
        image = pygame.image.load('./pics/beholder2-48x48.bmp').convert()
        image.set_colorkey((255,0,0)) 
	self.stimlib.addpicture(image)
        image = pygame.image.load('./pics/beholder3-48x48.bmp').convert()
        image.set_colorkey((255,0,0)) 
	self.stimlib.addpicture(image)	
        image = pygame.image.load('./pics/beholder4-48x48.bmp').convert()
        image.set_colorkey((255,0,0)) 
	self.stimlib.addpicture(image)
        image = pygame.image.load('./pics/beholder5-48x48.bmp').convert()
        image.set_colorkey((255,0,0)) 
	self.stimlib.addpicture(image)	
        image = pygame.image.load('./pics/beholder6-48x48.bmp').convert()
        image.set_colorkey((255,0,0)) 
	self.stimlib.addpicture(image)
        image = pygame.image.load('./pics/beholder7-48x48.bmp').convert()
        image.set_colorkey((255,0,0)) 
	self.stimlib.addpicture(image)	
        image = pygame.image.load('./pics/beholder8-48x48.bmp').convert()
        image.set_colorkey((255,0,0)) 
	self.stimlib.addpicture(image)
        image = pygame.image.load('./pics/beholder9-48x48.bmp').convert()
        image.set_colorkey((255,0,0)) 
	self.stimlib.addpicture(image)
        image = pygame.image.load('./pics/beholder10-48x48.bmp').convert()
        image.set_colorkey((255,0,0)) 
	self.stimlib.addpicture(image)
        image = pygame.image.load('./pics/beholder11-48x48.bmp').convert()
        image.set_colorkey((255,0,0)) 
	self.stimlib.addpicture(image)
        image = pygame.image.load('./pics/beholder12-48x48.bmp').convert()
        image.set_colorkey((255,0,0)) 
	self.stimlib.addpicture(image)
        image = pygame.image.load('./pics/beholder13-48x48.bmp').convert()
        image.set_colorkey((255,0,0)) 
	self.stimlib.addpicture(image)
        image = pygame.image.load('./pics/beholder14-48x48.bmp').convert()
        image.set_colorkey((255,0,0)) 
	self.stimlib.addpicture(image)

        image = pygame.image.load('./pics/beholderup1-48x48.bmp').convert()
        image.set_colorkey((255,0,0)) 
	self.stimlibup.addpicture(image)
        image = pygame.image.load('./pics/beholderup2-48x48.bmp').convert()
        image.set_colorkey((255,0,0)) 
	self.stimlibup.addpicture(image)

	self.talkcounter = 0
	self.direction = "left"

    def draw(self, screen, room):
	if self.direction == "up":
        	self.stimlibup.draw(screen, self.x+room.relativex,self.y+room.relativey)
        else:
		self.stimlib.draw(screen, self.x+room.relativex,self.y+room.relativey)
	    
	     
    def update(self,room,player):
        sleep(.04) # FIX goblin sleep
	if room.collidewithenemy(self):
	    if (self.direction == "right"):
	        self.x -=6
	        self.direction = "left" 
	    elif (self.direction == "left"):
	        self.x +=6
	        self.direction = "right"
	    elif (self.direction == "down"):
	        self.y -=6
	        self.direction = "up" 
	    elif (self.direction == "up"):
	        self.y +=6
	        self.direction = "down"

	if player.x+28-room.relativex < self.x:
		self.x -= 3
		self.direction = "left"
	if player.x-28-room.relativex > self.x:
		self.direction = "right"
		self.x += 3	
	if player.y+10-room.relativey < self.y:
		self.direction = "up"
		self.y -= 3
	if player.y-10-room.relativey > self.y:
		self.direction = "down"
		self.y += 3

    def collide(self, room, player):
        # FIX BUG
        #print 'gameobject x=%d y=%d player x=%d y=%d' % (self.x,self.y,player.x-room.relativex,player.y-room.relativey)
	if (player.x-room.relativex > self.x-self.w  and 
	player.x-room.relativex < self.x+self.w+self.w and 
	player.y-room.relativey > self.y-self.h and 
	player.y-room.relativey < self.y + self.h +self.h):
	    #print "collision with Game Object!"
	    return 1 
	else:
	    return 0 ## for game self.talker


    def fight(self,room,player):
        self.fightcounter = 1
        o = player.collidewithenemyweapon(room,self)
        if o:
            player.hitwithenemyweapon(RNG().rollbeholderzap())

# Copyright (C) Johan Ceuppens 2010
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


import pygame
from pygame.locals import *
from gameobject import *
from stateimagelibrary import *
import random
from time import *

class BlackKnight(Gameobject):
    "BlackKnight"
    def __init__(self,xx,yy):
	Gameobject.__init__(self, xx, yy)
        self.w = 36
        self.h = 36 
	self.stimlibleft = Stateimagelibrary()	
	self.stimlibright = Stateimagelibrary()	
        image = pygame.image.load('./pics/knightdarkleft1-30x30.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)	
        image = pygame.image.load('./pics/knightdarkleft2-30x30.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)	
        image = pygame.image.load('./pics/knightdarkleft3-30x30.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)	

        image = pygame.image.load('./pics/knightdarkright1-30x30.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibright.addpicture(image)	
        image = pygame.image.load('./pics/knightdarkright2-30x30.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibright.addpicture(image)	
        image = pygame.image.load('./pics/knightdarkright3-30x30.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibright.addpicture(image)	

	self.direction = "left"

    def draw(self, screen, room):
	if (self.direction == "left"):
            self.stimlibleft.draw(screen, self.x+room.relativex,self.y+room.relativey)
	elif (self.direction == "right"):
            self.stimlibright.draw(screen, self.x+room.relativex,self.y+room.relativey)
	    
	     
    def update(self,room):
        sleep(.01) # FIX darkkngith sleep
	if (random.randint(0,100) == 0 and self.direction == "left"):
	   self.direction = "right"
	elif (random.randint(0,100) == 0 and self.direction == "right"):
	   self.direction = "left"

	if (not self.collideobjectX(room)): 
	    if (self.direction == "left"):
	        self.x +=2
	        self.direction = "right" 
	    elif (self.direction == "right"):
	        self.x -=2
	        self.direction = "left"


	if (self.direction == "left"):
	        self.x -=1 
	elif (self.direction == "right"):
	        self.x +=1

    def collide(self, room, player):
	if (player.x > self.x+room.relativex  and 
	player.x < self.x+room.relativex+self.w and 
	player.y > self.y+room.relativey and 
	player.y < self.y+room.relativey + self.h):
	    print "collision with Dark Knight!"
	    if player.hit():
		return 1 
	    else:
	    	return 2 
	else:
	    return 0

		 

# Copyright (C) Johan Ceuppens 2010
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


import pygame
from pygame.locals import *
from gameobject import *
from stateimagelibrary import *
import random

class BlackKnightStanding(Gameobject):
    "BlackKnight"
    def __init__(self,xx,yy):
	Gameobject.__init__(self, xx, yy)
        self.w = 36
        self.h = 36 
	self.stimlibleft = Stateimagelibrary()	
	self.stimlibright = Stateimagelibrary()	
        image = pygame.image.load('./pics/darknut1-36x36.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)	
        image = pygame.image.load('./pics/darknut2-36x36.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibright.addpicture(image)	
	self.direction = "left"

    def draw(self, screen, room):
	if (self.direction == "left"):
            self.stimlibleft.draw(screen, self.x+room.relativex,self.y+room.relativey)
	elif (self.direction == "right"):
            self.stimlibright.draw(screen, self.x+room.relativex,self.y+room.relativey)
	    
	     
    def update(self,room):
	if (random.randint(0,100) == 0 and self.direction == "left"):
	   self.direction = "right"
	elif (random.randint(0,100) == 0 and self.direction == "right"):
	   self.direction = "left"
 
	if (self.direction == "left" and self.collide(room,self)):
	    self.x -= 1 
	elif (self.direction == "right" and self.collide(room,self)):
	    self.x += 1 


# Copyright (C) Johan Ceuppens 2010
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


import pygame
from pygame.locals import *
from gameobject import *
from stateimagelibrary import *
import random

class Bombman(Gameobject):
    "Bombman"
    def __init__(self,xx,yy):
	Gameobject.__init__(self, xx, yy)
        self.w = 36
        self.h = 36 

	self.stimlibburning = Stateimagelibrary()
	for i in range(0,15):	
        	image = pygame.image.load('./pics/bombburning1-24x24.bmp').convert()
        	image.set_colorkey((255,255,255)) 
		self.stimlibburning.addpicture(image)	
	for i in range(0,15):	
        	image = pygame.image.load('./pics/bombburning2-24x24.bmp').convert()
        	image.set_colorkey((255,255,255)) 
		self.stimlibburning.addpicture(image)	
	for i in range(0,15):	
        	image = pygame.image.load('./pics/bombburning3-24x24.bmp').convert()
        	image.set_colorkey((255,255,255)) 
		self.stimlibburning.addpicture(image)	
	for i in range(0,15):	
        	image = pygame.image.load('./pics/bomb1-24x24.bmp').convert()
        	image.set_colorkey((255,255,255)) 
		self.stimlibburning.addpicture(image)
	for i in range(0,5):	
        	image = pygame.image.load('./pics/bombred1-24x24.bmp').convert()
        	image.set_colorkey((255,255,255)) 
		self.stimlibburning.addpicture(image)
	for i in range(0,5):	
        	image = pygame.image.load('./pics/bomb1-24x24.bmp').convert()
        	image.set_colorkey((255,255,255)) 
		self.stimlibburning.addpicture(image)
	for i in range(0,5):	
        	image = pygame.image.load('./pics/bombred1-24x24.bmp').convert()
        	image.set_colorkey((255,255,255)) 
		self.stimlibburning.addpicture(image)
	for i in range(0,5):	
        	image = pygame.image.load('./pics/bomb1-24x24.bmp').convert()
        	image.set_colorkey((255,255,255)) 
		self.stimlibburning.addpicture(image)
	for i in range(0,5):	
        	image = pygame.image.load('./pics/bombred1-24x24.bmp').convert()
        	image.set_colorkey((255,255,255)) 
		self.stimlibburning.addpicture(image)
	for i in range(0,5):	
        	image = pygame.image.load('./pics/bomb1-24x24.bmp').convert()
        	image.set_colorkey((255,255,255)) 
		self.stimlibburning.addpicture(image)
	self.stimlibleft = Stateimagelibrary()	
	self.stimlibright = Stateimagelibrary()	
        image = pygame.image.load('./pics/bombmanleft1-36x36.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)	
        image = pygame.image.load('./pics/bombmanleft1-36x36.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)	
        image = pygame.image.load('./pics/bombmanleft1-36x36.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)	
        image = pygame.image.load('./pics/bombmanleft2-36x36.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)	
        image = pygame.image.load('./pics/bombmanleft2-36x36.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)	
        image = pygame.image.load('./pics/bombmanleft2-36x36.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)	
        image = pygame.image.load('./pics/bombmanleft3-36x36.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)	
        image = pygame.image.load('./pics/bombmanleft3-36x36.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)	
        image = pygame.image.load('./pics/bombmanleft3-36x36.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)	
        image = pygame.image.load('./pics/bombmanleft2-36x36.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)	
        image = pygame.image.load('./pics/bombmanleft2-36x36.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)	
        image = pygame.image.load('./pics/bombmanleft2-36x36.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)	

        image = pygame.image.load('./pics/bombman1-36x36.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibright.addpicture(image)	
        image = pygame.image.load('./pics/bombman1-36x36.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibright.addpicture(image)	
        image = pygame.image.load('./pics/bombman1-36x36.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibright.addpicture(image)	
        image = pygame.image.load('./pics/bombman2-36x36.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibright.addpicture(image)	
        image = pygame.image.load('./pics/bombman2-36x36.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibright.addpicture(image)	
        image = pygame.image.load('./pics/bombman2-36x36.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibright.addpicture(image)	
        image = pygame.image.load('./pics/bombman3-36x36.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibright.addpicture(image)	
        image = pygame.image.load('./pics/bombman3-36x36.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibright.addpicture(image)	
        image = pygame.image.load('./pics/bombman3-36x36.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibright.addpicture(image)	
        image = pygame.image.load('./pics/bombman2-36x36.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibright.addpicture(image)	

	self.direction = "left"

    def draw(self, screen, room):
	###print "self.direction=%s" % self.direction
	if (self.direction == "left"):
            self.stimlibleft.draw(screen, self.x+room.relativex,self.y+room.relativey)
	elif (self.direction == "right"):
            self.stimlibright.draw(screen, self.x+room.relativex,self.y+room.relativey)
	elif (self.direction == "burning"):    
            self.stimlibburning.draw(screen, self.x+room.relativex,self.y+room.relativey)
	    if self.stimlibburning.index >= self.stimlibburning.max:
	    	room.removeobject(self)
	    
	     
    def update(self,room):
	#print "self.direction=%s" % self.direction
	
	if self.direction == "burning":
		return

	if (random.randint(0,100) == 0 and self.direction == "left"):
	   self.direction = "right"
	elif (random.randint(0,100) == 0 and self.direction == "right"):
	   self.direction = "left"

	if (not self.collideobjectX(room)): 
	    if (self.direction == "left"):
	        self.x +=2
	        self.direction = "right" 
	    elif (self.direction == "right"):
	        self.x -=2
	        self.direction = "left"


	if (self.direction == "left"):
	        self.x -=1 
	elif (self.direction == "right"):
	        self.x +=1

    def collide(self, room, player):
	if (player.x > self.x+room.relativex  and 
	player.x < self.x+room.relativex+self.w and 
	player.y > self.y+room.relativey and 
	player.y < self.y+room.relativey + self.h):
		print "collision with Bombman!"
	    ###if player.hit():## FIX player needs descending hearts in meter
       		self.direction = "burning"
	return 0 
	    #else:
	    #	return 2 
	#else:
	 #   return 0

		 

# Copyright (C) Johan Ceuppens 2010 
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


import pygame
from pygame.locals import *
from gameobject import *

class Bomb(Gameobject):
    ""
    def __init__(self, xx,yy):
        Gameobject.__init__(self,xx,yy)
        self.w = 16 
        self.h = 16 
        self.image = pygame.image.load('./pics/bomb1-16x16.bmp').convert()
        self.image.set_colorkey((0,0,0)) 
   	self.counter = 0 


    def update(self,room):
	self.counter += 1
	j = 0
	if (self.counter > 50):
	    for i in room.gameobjects:
		if (i == self):
		    l = 0
		    for k in room.gameobjects: 
			if i != k and k and k.collideobjectXY(room):
			    room.gameobjects[l] = None
			l += 1    	
		    room.gameobjects[j] = None 
		    return
	    	j += 1 

# Copyright (C) Johan Ceuppens 2010 
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


import pygame
from pygame.locals import *
from gameobject import *

class Box(Gameobject):
    "Box"
    def __init__(self, xx,yy,ww,hh):
        Gameobject.__init__(self,xx,yy)
        self.w = ww
        self.h = hh 
        #FIX is in base class self.image = pygame.image.load('./pics/.bmp').convert()
        #self.image.set_colorkey((0,0,0)) 

    def setimage(self, imagefilename,r,g,b):
        self.image = pygame.image.load(imagefilename).convert()
        self.image.set_colorkey((r,g,b)) 

    def collide(self, room, player):
	if (player.x > self.x+room.relativex  and 
	player.x < self.x+room.relativex+self.w and 
	player.y > self.y+room.relativey and 
	player.y < self.y+room.relativey + self.h):
	    print "collision in box!"	
	    return 2 
	else:
	    return 0

# Copyright (C) Johan Ceuppens 2010
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


import pygame
from pygame.locals import *
from gameobject import *
from stateimagelibrary import *
import random
from rng import *

class BroadSword(Gameobject):
    "Ruby Sword"
    def __init__(self,xx,yy):
	Gameobject.__init__(self, xx, yy)
        self.w = 36
        self.h = 36
	self.stimlib = Stateimagelibrary()		
        image = pygame.image.load('./pics/taskbar-defaultsword1-32x32.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlib.addpicture(image)	
	

    def draw(self, screen, room):
        self.stimlib.draw(screen, self.x+room.relativex,self.y+room.relativey)
	
	     
    def update(self,room,player):
	1

    def pickup(self, room):
        room.removeobject(self)
	return 5

    def collide(self, room, player):
        ###print 'gameobject x=%d y=%d player x=%d y=%d' % (self.x,self.y,player.x-room.relativex,player.y-room.relativey)
	return  5 

    def roll(self):
	return RNG().rollbroadsword()

# Copyright (C) Johan Ceuppens 2010 
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


import pygame
from pygame.locals import *
from gameobject import *

class Dungeonbrokenwall(Gameobject):
    ""
    def __init__(self, xx,yy):
        Gameobject.__init__(self,xx,yy)
        self.w = 48 
        self.h = 48
        self.image = pygame.image.load('./pics/brokenwall-48x48.bmp').convert()
        self.image.set_colorkey((0,0,0)) 


# Copyright (C) Johan Ceuppens 2010
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


import pygame
from pygame.locals import *
from gameobject import *
from stateimagelibrary import *
import random
from time import *

class Butterfly2(Gameobject):
    ""
    def __init__(self,xx,yy):
	Gameobject.__init__(self, xx, yy)
        self.w = 16
        self.h = 16 
	self.stimlib = Stateimagelibrary()
        image = pygame.image.load('./pics/butterfly1-16x16.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlib.addpicture(image)	
        image = pygame.image.load('./pics/butterfly2-16x16.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlib.addpicture(image)
	image = pygame.image.load('./pics/butterfly3-16x16.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlib.addpicture(image)
	image = pygame.image.load('./pics/butterfly4-16x16.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlib.addpicture(image)

	self.direction = "left"

    def draw(self, screen, room):
        self.stimlib.draw(screen, self.x+room.relativex,self.y+room.relativey)    
	     
    def update(self,room,player):
        #sleep(.005)
##        self.x-=1

        r = random.randint(0,4)
	if (r == 0):
	   self.direction = "right"
        if (r == 1):
	   self.direction = "left"
        if (r == 2):
	   self.direction = "up"
	if (r == 3):
	   self.direction = "down"

	if (not self.collideobjectX(room)): 
	    if (self.direction == "left"):
	        self.x +=2
	        self.direction = "right" 
	    elif (self.direction == "right"):
	        self.x -=2
	        self.direction = "left"

	if (not self.collideobjectY(room)): 
	    if (self.direction == "up"):
	        self.x +=2
	        self.direction = "down" 
	    elif (self.direction == "down"):
	        self.x -=2
	        self.direction = "up"


	if (self.direction == "left"):
	        self.x -=1 
	elif (self.direction == "right"):
	        self.x +=1
	elif (self.direction == "down"):
	        self.y +=1
	elif (self.direction == "up"):
	        self.y -=1
	        

    def collide(self, room, player):
	if (player.x > self.x+room.relativex  and 
	player.x < self.x+room.relativex+self.w and 
	player.y > self.y+room.relativey and 
	player.y < self.y+room.relativey + self.h):
##	    print "collision with Butterfly!"
            return 2
    	return 0

		 

# Copyright (C) Johan Ceuppens 2010
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


import pygame
from pygame.locals import *
from gameobject import *
from stateimagelibrary import *
import random
from time import *

class Butterfly(Gameobject):
    ""
    def __init__(self,xx,yy):
	Gameobject.__init__(self, xx, yy)
        self.w = 16
        self.h = 16 
	self.stimlib = Stateimagelibrary()
        image = pygame.image.load('./pics/butterfly1-16x16.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlib.addpicture(image)	
        image = pygame.image.load('./pics/butterfly2-16x16.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlib.addpicture(image)
	image = pygame.image.load('./pics/butterfly3-16x16.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlib.addpicture(image)
	image = pygame.image.load('./pics/butterfly4-16x16.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlib.addpicture(image)

	self.direction = "left"

    def draw(self, screen, room):
        self.stimlib.draw(screen, self.x+room.relativex,self.y+room.relativey)    
	     
    def update(self,room,player):
        #sleep(.005)
##        self.x-=1
	if (random.randint(0,14) == 0 and self.direction == "left"):
	   self.direction = "right"
        if (random.randint(0,13) == 0 and self.direction == "right"):
	   self.direction = "left"
        if (random.randint(0,12) == 0 and self.direction == "down"):
	   self.direction = "up"
	if (random.randint(0,10) == 0 and self.direction == "up"):
	   self.direction = "down"

	if (not self.collideobjectX(room)): 
	    if (self.direction == "left"):
	        self.x +=2
	        self.direction = "right" 
	    elif (self.direction == "right"):
	        self.x -=2
	        self.direction = "left"

	if (not self.collideobjectY(room)): 
	    if (self.direction == "up"):
	        self.x +=2
	        self.direction = "down" 
	    elif (self.direction == "down"):
	        self.x -=2
	        self.direction = "up"


	if (self.direction == "left"):
	        self.x -=1 
	elif (self.direction == "right"):
	        self.x +=1
	elif (self.direction == "down"):
	        self.y +=1
	elif (self.direction == "up"):
	        self.y -=1
	        

    def collide(self, room, player):
	if (player.x > self.x+room.relativex  and 
	player.x < self.x+room.relativex+self.w and 
	player.y > self.y+room.relativey and 
	player.y < self.y+room.relativey + self.h):
	    print "collision with Butterfly!"
	return 0

		 

# Copyright (C) Johan Ceuppens 2010
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


import pygame
from pygame.locals import *
from gameobject import *
from stateimagelibrary import *
import random
from time import *
from meter import *
from rng import *
from random import *

class Centaur1(Gameobject):
    "Centaur"
    def __init__(self,xx,yy,aiengine):
	Gameobject.__init__(self, xx, yy)
        self.w = 48
        self.h = 48

        self.aiengine = aiengine

        self.hitpoints = 20
        self.meter = Meter()
        self.meter.setmax(self.hitpoints)        
	self.stimlibdown = Stateimagelibrary()	
	self.stimlibup = Stateimagelibrary()	
        image = pygame.image.load('./pics/centaur1-64x64.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibup.addpicture(image)	
        
	image = pygame.image.load('./pics/centaur1-64x64.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibdown.addpicture(image)  

	self.talkcounter = 0
	self.direction = "down"

    def draw(self, screen, room):
	#if (self.direction == "down"):
        self.stimlibdown.draw(screen, self.x+room.relativex,self.y+room.relativey)
        if self.battlemode:
            self.meter.drawat(screen,self.x+room.relativex,self.y+room.relativey)
	#elif (self.direction == "up"):
        #    self.stimlibup.draw(screen, self.x+room.relativex,self.y+room.relativey)
	    
    def fight(self,room,player):
        if self.battlemode:
            self.aiengine.overallattack()
        #o = player.collidewithenemyweapon(room,self)
        #if o:
        # NOTE: Longbow shoots from a distance
            player.hitwithenemyweapon(RNG().rolllongbow())
            
    def update(self,room,player):
        # NOTE: 300 pixel distance maximum for longbow shooting
        if self.battlemode:
            if player.x-300 < self.x:
                self.x -= 10
            if player.x+300 > self.x:
                self.x += 10
            if player.y-300 < self.y:
                self.y -= 10
            if player.y+300 > self.y:
                self.y += 10
            self.fight(room, player)
            
        r = randint(0,80)
        if r == 0:
            self.direction = "left"
        elif r == 1:
            self.direction = "right"
        elif r == 2:
            self.direction = "up"
        elif r == 3:
            self.direction = "down"
	
	if ( self.collideobjectXY(room)): 
	    if (self.direction == "down"):
	        self.y -=2
	        self.direction = "up" 
	    elif (self.direction == "up"):
	        self.y +=2
	        self.direction = "down"

	if (self.direction == "up"):
	        self.y -=1 
	elif (self.direction == "down"):
	        self.y +=1
	elif (self.direction == "right"):
	        self.x +=1
	elif (self.direction == "left"):
	        self.x -=1

    def collide(self, room, player):
        # FIX BUG
        #print 'centaur x=%d y=%d player x=%d y=%d' % (self.x,self.y,player.x-room.relativex,player.y)
	if (player.x-room.relativex > self.x  and 
	player.x-room.relativex < self.x+self.w and 
	player.y-room.relativey > self.y and 
	player.y-room.relativey < self.y + self.h):
	    #print "collision with Centaur!"
	    return 2 
	else:
	    return 0 ## for game self.talker

##    def hitwithweapon(self,damage):
##	if damage > 0:
##            print 'enemy is hit!'
##        self.hitpoints -= damage
##        # FIXME in all enemies
##        self.meter.index -= damage


    def talk(self, screen,font):
        if self.talkcounter == 0:
            return
 
        pygame.key.set_repeat(1000,1000)
        
        talkover = 0
        while talkover == 0:
            pygame.display.update()
            if self.talkcounter == 1:
                screen.blit(font.render("You are in Centaur Glade.", 6, (255,255,255)), (10,100))
                #sleep(3)
            elif self.talkcounter == 2:
                screen.blit(font.render("I am Colin.", 6, (255,255,255)), (10,120))
                #sleep(3)
            elif self.talkcounter == 3:
                pygame.key.set_repeat(1,1)
                self.talkcounter = 0
                talkover = 1
            for event in pygame.event.get():
                if event.type == QUIT:
                    return
                elif event.type == KEYDOWN:
                    if event.key == K_z:
                        talkover = 1
                        self.talkcounter = 0
                        pygame.key.set_repeat(1,1)
                    if event.key == K_x:
                        self.talkcounter += 1
                

# Copyright (C) Johan Ceuppens 2010
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


import pygame
from pygame.locals import *
from gameobject import *
from stateimagelibrary import *
import random
from time import *

class Demon(Gameobject):
    "Demon"
    def __init__(self,xx,yy):
	Gameobject.__init__(self, xx, yy)
        self.w = 36
        self.h = 36 
	self.stimlibleft = Stateimagelibrary()	
	self.stimlibright = Stateimagelibrary()
	self.stimlibup = Stateimagelibrary()	
	self.stimlibdown = Stateimagelibrary()	
        image = pygame.image.load('./pics/demon1-36x36.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibleft.addpicture(image)
	self.stimlibright.addpicture(image)
	self.stimlibup.addpicture(image)
	self.stimlibdown.addpicture(image)
	image = pygame.image.load('./pics/demon1-36x36.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibleft.addpicture(image)
	self.stimlibright.addpicture(image)
	self.stimlibup.addpicture(image)
	self.stimlibdown.addpicture(image)
	image = pygame.image.load('./pics/demon1-36x36.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibleft.addpicture(image)
	self.stimlibright.addpicture(image)
	self.stimlibup.addpicture(image)
	self.stimlibdown.addpicture(image)
	image = pygame.image.load('./pics/demon1-36x36.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibleft.addpicture(image)
	self.stimlibright.addpicture(image)
	self.stimlibup.addpicture(image)
	self.stimlibdown.addpicture(image)
	image = pygame.image.load('./pics/demon2-36x36.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibleft.addpicture(image)
	self.stimlibright.addpicture(image)
	self.stimlibup.addpicture(image)
	self.stimlibdown.addpicture(image)
	image = pygame.image.load('./pics/demon2-36x36.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibleft.addpicture(image)
	self.stimlibright.addpicture(image)
	self.stimlibup.addpicture(image)
	self.stimlibdown.addpicture(image)
	image = pygame.image.load('./pics/demon2-36x36.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibleft.addpicture(image)
	self.stimlibright.addpicture(image)
	self.stimlibup.addpicture(image)
	self.stimlibdown.addpicture(image)
	image = pygame.image.load('./pics/demon2-36x36.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibleft.addpicture(image)
	self.stimlibright.addpicture(image)
	self.stimlibup.addpicture(image)
	self.stimlibdown.addpicture(image)
	image = pygame.image.load('./pics/demon3-36x36.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibleft.addpicture(image)
	self.stimlibright.addpicture(image)
	self.stimlibup.addpicture(image)
	self.stimlibdown.addpicture(image)
	image = pygame.image.load('./pics/demon3-36x36.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibleft.addpicture(image)
	self.stimlibright.addpicture(image)
	self.stimlibup.addpicture(image)
	self.stimlibdown.addpicture(image)
	image = pygame.image.load('./pics/demon3-36x36.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibleft.addpicture(image)
	self.stimlibright.addpicture(image)
	self.stimlibup.addpicture(image)
	self.stimlibdown.addpicture(image)
	image = pygame.image.load('./pics/demon3-36x36.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibleft.addpicture(image)
	self.stimlibright.addpicture(image)
	self.stimlibup.addpicture(image)
	self.stimlibdown.addpicture(image)
	image = pygame.image.load('./pics/demon2-36x36.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibleft.addpicture(image)
	self.stimlibright.addpicture(image)
	self.stimlibup.addpicture(image)
	self.stimlibdown.addpicture(image)
	image = pygame.image.load('./pics/demon2-36x36.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibleft.addpicture(image)
	self.stimlibright.addpicture(image)
	self.stimlibup.addpicture(image)
	self.stimlibdown.addpicture(image)
	image = pygame.image.load('./pics/demon2-36x36.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibleft.addpicture(image)
	self.stimlibright.addpicture(image)
	self.stimlibup.addpicture(image)
	self.stimlibdown.addpicture(image)
	image = pygame.image.load('./pics/demon2-36x36.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibleft.addpicture(image)
	self.stimlibright.addpicture(image)
	self.stimlibup.addpicture(image)
	self.stimlibdown.addpicture(image)
	
        self.direction = "north"
        
    def draw(self, screen, room):
	if (self.direction == "left"):
            self.stimlibleft.draw(screen, self.x+room.relativex,self.y+room.relativey)
	elif (self.direction == "right"):
            self.stimlibright.draw(screen, self.x+room.relativex,self.y+room.relativey)
	elif (self.direction == "up"):
            self.stimlibup.draw(screen, self.x+room.relativex,self.y+room.relativey)
	elif (self.direction == "down"):
            self.stimlibright.draw(screen, self.x+room.relativex,self.y+room.relativey)
	    
	     
    def update(self,room):
        #FIXME elif
        sleep(.01)
	if (random.randint(0,5000) == 0):# and self.direction == "left"):
	   self.direction = "right"
	if (random.randint(0,5000) == 0):# and self.direction == "right"):
	   self.direction = "left"
        if (random.randint(0,5000) == 0):# and self.direction == "up"):
	   self.direction = "down"
	if (random.randint(0,5000) == 0):# and self.direction == "down"):
	   self.direction = "up"

	if (not self.collideobjectX(room)): 
	    if (self.direction == "left"):
	        self.x +=2
	        self.direction = "right" 
	    elif (self.direction == "right"):
	        self.x -=2
	        self.direction = "left"

        if (not self.collideobjectY(room)): 
	    if (self.direction == "up"):
	        self.y +=2
	        self.direction = "down" 
	    elif (self.direction == "down"):
	        self.y -=2
	        self.direction = "up"

	if (self.direction == "left"):
	    self.x -=1 
	elif (self.direction == "right"):
	    self.x +=1
	elif (self.direction == "up"):
	    self.y -=1
	elif (self.direction == "down"):
	    self.y +=1

# Copyright (C) Johan Ceuppens 2010
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


import pygame
from pygame.locals import *
from gameobject import *

class Dungeonentrance1(Gameobject):
    "Dungeon entrance 1"
    def __init__(self, xx,yy):
	Gameobject.__init__(self,xx,yy)	
	self.w = 200 
        self.h = 100 
        self.image = pygame.image.load('./pics/dungeon-entrance1-200x100.bmp').convert()
        self.image.set_colorkey((0,0,0)) 



# Copyright (C) Johan Ceuppens 2010
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


import pygame
from pygame.locals import *
from gameobject import *

class Dungeonentrance2(Gameobject):
    "Dungeon entrance 1"
    def __init__(self, xx,yy):
	Gameobject.__init__(self,xx,yy)	
	self.w = 70
        self.h = 70 
        self.image = pygame.image.load('./pics/dungeon-entrance2-48x48.bmp').convert()
        self.image.set_colorkey((0,0,0)) 

    def collide(self, room, player):
	if (player.x > self.x+room.relativex  and 
	player.x < self.x+room.relativex+self.w and 
	player.y > self.y+room.relativey and 
	player.y < self.y+room.relativey + self.h):
	    print "collision with Dungeon Entrance 2! x=%d y=%d" % (room.relativex,room.relativey) 
	    ###if player.hit():
	    return 3 ###NOTE 3 for dungeon walls and entrances bounc back ## 4 ?
	return 0

    ### NOTE: dungeon master key gets checked in game.py and this opens with return 2
    def pickup(self, room):
        ###room.removeobject(self)
	return 2

# Copyright (C) Johan Ceuppens 2010
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


import pygame
from pygame.locals import *
from gameobject import *
from stateimagelibrary import *
import random

class Dungeonkey1(Gameobject):
    "Darknut"
    def __init__(self,xx,yy):
	Gameobject.__init__(self, xx, yy)
        self.w = 36
        self.h = 36
	self.stimlib = Stateimagelibrary()		
        image = pygame.image.load('./pics/dungeonkey1-36x36.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlib.addpicture(image)	
	

    def draw(self, screen, room):
        self.stimlib.draw(screen, self.x+room.relativex,self.y+room.relativey)
	
	     
    def update(self,room,player):
	1

    def pickup(self, room):
        room.removeobject(self)
	return 3

    #def collide(self, room, player):

	#    return 0

        

# Copyright (C) Johan Ceuppens 2010
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


import pygame
from pygame.locals import *
from gameobject import *
from stateimagelibrary import *
import random

class Dungeonkey2GohmaLair(Gameobject):
    "Darknut"
    def __init__(self,xx,yy):
	Gameobject.__init__(self, xx, yy)
        self.w = 36
        self.h = 36
	self.stimlib = Stateimagelibrary()		
        image = pygame.image.load('./pics/dungeonkey1-36x36.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlib.addpicture(image)	
	

    def draw(self, screen, room):
        self.stimlib.draw(screen, self.x+room.relativex,self.y+room.relativey)
	
	     
    def update(self,room):
	1

    def pickup(self, room):
        room.removeobject(self)
	return 4

    def collide(self, room, player):
	    return 0

        

# Copyright (C) Johan Ceuppens 2010
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


import pygame
from pygame.locals import *
from gameobject import *
from stateimagelibrary import *
import random

class Dungeonmasterkey(Gameobject):
    "Darknut"
    def __init__(self,xx,yy):
	Gameobject.__init__(self, xx, yy)
        self.w = 36
        self.h = 36
	self.stimlib = Stateimagelibrary()		
        image = pygame.image.load('./pics/dungeonmasterkey1-36x36.bmp').convert()
        image.set_colorkey((255,255,255)) 
	self.stimlib.addpicture(image)	
	

    def draw(self, screen, room):
        self.stimlib.draw(screen, self.x+room.relativex,self.y+room.relativey)
	
	     
    def update(self,room):
	1

    def pickup(self, room):
        room.removeobject(self)
	return 1

    def collide(self, room, player):
	return 0

        

# Copyright (C) Johan Ceuppens 2010 
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


import pygame
from pygame.locals import *
from gameobject import *

class Dungeonstatue1(Gameobject):
    ""
    def __init__(self, xx,yy):
        Gameobject.__init__(self,xx,yy)
        self.w = 36 
        self.h = 36 
        self.image = pygame.image.load('./pics/dungeon-statue1-36x36.bmp').convert()
        self.image.set_colorkey((0,0,0)) 
    
    def collide(self, room, player):
	return 0

# Copyright (C) Johan Ceuppens 2010 
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


import pygame
from pygame.locals import *
from gameobject import *

class Dungeonstatue2(Gameobject):
    ""
    def __init__(self, xx,yy):
        Gameobject.__init__(self,xx,yy)
        self.w = 48
        self.h = 92 
        self.image = pygame.image.load('./pics/dungeon-statue2-48x92.bmp').convert()
        self.image.set_colorkey((255,255,255)) 
    
    def collide(self, room, player):
	return 0

# Copyright (C) Johan Ceuppens 2010 
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


import pygame
from pygame.locals import *
from gameobject import *

class Dungeonstatue3(Gameobject):
    ""
    def __init__(self, xx,yy):
        Gameobject.__init__(self,xx,yy)
        self.w = 48
        self.h = 92 
        self.image = pygame.image.load('./pics/dungeon-statue3-48x92.bmp').convert()
        self.image.set_colorkey((255,255,255)) 
    
    def collide(self, room, player):
	return 0

# Copyright (C) Johan Ceuppens 2010
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


import pygame
from pygame.locals import *
from gameobject import *

class Dungeonwall(Gameobject):
    ""
    def __init__(self, xx,yy,ww,hh):
        Gameobject.__init__(self,xx,yy)
        self.w = ww 
        self.h = hh
    
    def draw(self, screen, room):
	1


    def collide(self, room, player):
	if (player.x > self.x+room.relativex  and 
	player.x < self.x+room.relativex+self.w and 
	player.y > self.y+room.relativey and 
	player.y < self.y+room.relativey + self.h):
	    print "collision with Dungeon Wall! x=%d y=%d" % (room.relativex,room.relativey) 
	    ###if player.hit():
	    return 3 # NOTE return 3 for dungeon wall
	    #else:
	    #	return 2 
	else:
	    return 0


# Copyright (C) Johan Ceuppens 2010 
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


import pygame
from pygame.locals import *

class Gameobject:
    "Game object"
    def __init__(self, xx,yy):
	self.x = xx 
        self.y = yy
	# default width and height 
        self.w = 48
        self.h = 48
        self.SCREENH = 300
        self.SCREENW = 300
        ## dungeon statue as default picture
        ## self.image = pygame.image.load('./pics/dungeon-statue1-36x36.bmp').convert()
        self.image = pygame.image.load('./pics/nopicture.bmp').convert()
        self.image.set_colorkey((0,0,0)) 
        self.hitpoints = 1
        # NOTE : decrease 1 hitpoint with default sword
        self.hitf = self.hit1
        self.meter = None
        self.battlemode = None
        
    def draw(self, screen, room):
        screen.blit(self.image,(self.x+room.relativex,self.y+room.relativey))
	    
	     
    def collidewithsword(self, room, player):
        #print 'gameobject x=%d y=%d player x=%d y=%d' % (self.x,self.y,player.x-room.relativex,player.y-room.relativey)
	if (player.x-room.relativex > self.x-self.w  and 
	player.x-room.relativex < self.x+self.w and 
	player.y-room.relativey > self.y-self.h and 
	player.y-room.relativey < self.y + self.h):
	    #print "collision with Game Object!"
	    return 1 
	else:
	    return 0

    def collide(self, room, player):
        # FIX BUG
        #print 'gameobject x=%d y=%d player x=%d y=%d' % (self.x,self.y,player.x-room.relativex,player.y-room.relativey)
	if (player.x-room.relativex > self.x  and 
	player.x-room.relativex < self.x+self.w and 
	player.y-room.relativey > self.y and 
	player.y-room.relativey < self.y + self.h):
	    #print "collision with Game Object!"
	    return 1 
	else:
	    return 0 ## for game self.talker

    def collidepickup(self, room, player):
        # FIX BUG
	if (player.x-room.relativex > self.x  and 
	player.x-room.relativex < self.x+self.w and 
	player.y-room.relativey > self.y+self.h and 
	player.y-room.relativey < self.y+ self.h):
	    #print "pickup collision!"	
	    return 3 
	else:
	    return 0 
    
    def collideobjectX(self, room):
	for i in room.gameobjects:
	    if i != None:	
	        if (self.x > i.x  and 
		    self.x < i.x+i.w):
	            return 1 
	return 0

    def collideobjectY(self, room):
	for i in room.gameobjects:
	    if i != None:	
	        if (self.y > i.y  and 
		    self.y < i.y+i.h):
	            return 1 
	return 0
 
    def collideobjectXY(self, room):
	for i in room.gameobjects:
	    if i:		
	        if (self.x > i.x  and 
	 	    self.x < i.x+i.w and 
	            self.y > i.y and 
	            self.y < i.y+i.h):
	            return 1 
	return 0 
    
    def update(self,room,player):
	1

    def pickup(self, room):
        return 0

    def hit1(self):## NOTE decreases hitpoints
        self.hitpoints -= 1
        return self.hitpoints

    def hit2(self):## NOTE decreases hitpoints
        self.hitpoints -= 2
        return self.hitpoints

    def hitwithweapon(self,damage):
	if damage > 0:
            print 'enemy is hit!'
        self.hitpoints -= damage
        self.battlemode = 1
        if self.meter:
            self.meter.index -= damage

    def fight(self,room,player):
	1
    
    def undomove(self):
	1
#!/usr/local/bin/python
# Copyright (C) Johan Ceupens 2010
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


import pygame
from pygame.locals import *

from maproom1 import *
from maproom2 import *

from taskbar import *
from selector import *
from time import *
from inventory import *
from heartmeter import *
from playermaker import *
from playercentaurfighter import *
from playerfairyfighter import *
from playerelffighter import *
from playergnomefighter import *
from playercentaurmagicuser import *
from playerfairymagicuser import *
from playerelfmagicuser import *
from playergnomemagicuser import *
from playercentaurpriest import *
from playerfairypriest import *
from playerelfpriest import *
from playergnomepriest import *
from playercentaurpaladin import *
from playerfairypaladin import *
from playerelfpaladin import *
from playergnomepaladin import *

from aimessagingsystem import *

class Game:
    "Main function"
    def __init__(self):
        pygame.init()
        pygame.font.init()
        screen = pygame.display.set_mode((640, 480))
        font = pygame.font.SysFont("Times", 14)
        font2 = pygame.font.SysFont("Vera", 28)
        font3 = pygame.font.SysFont("Courier", 10)
        gameover = 0

        askplayers = 0 # NOTE: 2 Player flag
        
        blankimage = pygame.image.load('./pics/blank.bmp').convert()
        ## There are several title screens in the ./pics/ directory
        titleimage = pygame.image.load('./pics/titlescreen0.4.bmp').convert()
        self.x = 0
        self.y = 0

        while gameover == 0:
            pygame.display.update()
            screen.blit(titleimage, (0,0))
            for event in pygame.event.get():
                if event.type == QUIT:
                    return
                elif event.type == KEYDOWN:
                    gameover = 1
                if event.type == pygame.MOUSEBUTTONDOWN:
                    gameover = 1
                    
        screen.blit(blankimage, (0,0))
        self.aiengine = AIMessagingSystem()
        self.room = Maproom1(0,0,self.aiengine)
        heartmeter = HeartMeter(3,470)

        plm = PlayerMaker()
        anotherchar = plm.start(screen)
        
        #selector = Selector(screen, font)
        #selector.select()
	player = None#PlayerFighter()##default fighter class
	if plm.askrace() == "Elf":
            if plm.askclass() == "Fighter":
                player = PlayerElfFighter(heartmeter)
            elif plm.askclass() == "Magic User":
                player = PlayerElfMagicUser(heartmeter)
            elif plm.askclass() == "Priest":
                player = PlayerElfPriest(heartmeter)
            elif plm.askclass() == "Paladin":
                player = PlayerElfPaladin(heartmeter)
        if plm.askrace() == "Centaur":
            if plm.askclass() == "Fighter":
                player = PlayerCentaurFighter(heartmeter)
            elif plm.askclass() == "Magic User":
                player = PlayerCentaurMagicUser(heartmeter)
            elif plm.askclass() == "Priest":
                player = PlayerCentaurPriest(heartmeter)
            elif plm.askclass() == "Paladin":
                player = PlayerCentaurPaladin(heartmeter)
        if plm.askrace() == "Fairy":
            if plm.askclass() == "Fighter":
                player = PlayerFairyFighter(heartmeter)
            elif plm.askclass() == "Magic User":
                player = PlayerFairyMagicUser(heartmeter)
            elif plm.askclass() == "Priest":
                player = PlayerFairyPriest(heartmeter)
            elif plm.askclass() == "Paladin":
                player = PlayerFairyPaladin(heartmeter)
        if plm.askrace() == "Gnome":
            if plm.askclass() == "Fighter":
                player = PlayerGnomeFighter(heartmeter)
            elif plm.askclass() == "Magic User":
                player = PlayerGnomeMagicUser(heartmeter)
            elif plm.askclass() == "Priest":
                player = PlayerGnomePriest(heartmeter)
            elif plm.askclass() == "Paladin":  
                player = PlayerGnomePaladin(heartmeter)
        player2 = None
        heartmeter2 = HeartMeter(103,470)
        if anotherchar:
            plm = PlayerMaker()
            plm.start(screen)
            
            #selector = Selector(screen, font)
            #selector.select()
            #PlayerFighter()##default fighter class
            if plm.askrace() == "Elf":
                if plm.askclass() == "Fighter":
                    player2 = PlayerElfFighter(heartmeter2)
                elif plm.askclass() == "Magic User":
                    player2 = PlayerElfMagicUser(heartmeter2)
                elif plm.askclass() == "Priest":
                    player2 = PlayerElfPriest(heartmeter2)
                elif plm.askclass() == "Paladin":
                    player2 = PlayerElfPaladin(heartmeter2)
            if plm.askrace() == "Centaur":
                if plm.askclass() == "Fighter":
                    player2 = PlayerCentaurFighter(heartmeter2)
                elif plm.askclass() == "Magic User":
                    player2 = PlayerCentaurMagicUser(heartmeter2)
                elif plm.askclass() == "Priest":
                    player2 = PlayerCentaurPriest(heartmeter2)
                elif plm.askclass() == "Paladin":
                    player2 = PlayerCentaurPaladin(heartmeter2)
            if plm.askrace() == "Fairy":
                if plm.askclass() == "Fighter":
                    player2 = PlayerFairyFighter(heartmeter2)
                elif plm.askclass() == "Magic User":
                    player2 = PlayerFairyMagicUser(heartmeter2)
                elif plm.askclass() == "Priest":
                    player2 = PlayerFairyPriest(heartmeter2)
                elif plm.askclass() == "Paladin":
                    player2 = PlayerFairyPaladin(heartmeter2)
            if plm.askrace() == "Gnome":
                if plm.askclass() == "Fighter":
                    player2 = PlayerGnomeFighter(heartmeter2)
                elif plm.askclass() == "Magic User":
                    player2 = PlayerGnomeMagicUser(heartmeter2)
                elif plm.askclass() == "Priest":
                    player2 = PlayerGnomePriest(heartmeter2)
                elif plm.askclass() == "Paladin":  
                    player2 = PlayerGnomePaladin(heartmeter2)

            if player2:
                player2.x += 60
                player2.y += 0

                
        self.inventoryitem = None
        self.inventorymasterkey = None
        self.inventorykey1 = None
        self.inventorykey2 = None
        self.inventoryrubysword = None
        
        self.taskbar = Taskbar(screen,font,player,player2)
        self.talkerlist = None

        self.position1stx = 0
        self.position1sty = 0
        self.position2ndx = 0
        self.position2ndy = 0
        self.positionmovex = 0
        self.positionmovey = 0        

        pygame.key.set_repeat(1,1)
        gameover = 0
        while gameover == 0:
                       
            for event in pygame.event.get():
                if event.type == QUIT:
                    return
                if event.type == pygame.MOUSEBUTTONDOWN:
                    ##FIXME righclick start ->
                    if pygame.mouse.get_pressed()[2]:
                        
                        # take room coords of mouse
                        mousepos = pygame.mouse.get_pos()
                        player.mousex = mousepos[0]-self.room.relativex
                        player.mousey = mousepos[1]-self.room.relativey
                        if player2:
                            player2.mousex = mousepos[0]-self.room.relativex
                            player2.mousey = mousepos[1]-self.room.relativey
                        
                        if self.room.automove == 0:
                            self.room.set_automove(player)
                            if player2:
                                self.room.set_automove(player2)
                        elif self.room.automove == 1:
                            self.room.automove = 0
                        break
                            
                    position1 = pygame.mouse.get_pos()
                    self.position1stx = position1[0]
                    self.position1sty = position1[1]

                    if self.collidewithclick(player,self.room,self.position1stx,self.position1sty,50,50):
                        player.highlight()
                        self.taskbar.highlight()
                    else:
                        if pygame.mouse.get_pressed()[0]:
                            player.unhighlight()
                    if player2: 
                        if self.collidewithclick(player2,self.room,self.position1stx,self.position1sty,50,50):
                            player2.highlight()
                            ## FIXME
                            self.taskbar.highlight()
                        else:
                            if pygame.mouse.get_pressed()[0]:
                                player2.unhighlight()

                        playerflag = self.taskbar.domouse(player,player2)
                        if playerflag == 0:
                            break
                        inventory = self.taskbar.openinventory(playerflag, font3)
                        if playerflag == 1:
                            inventory.setrow1(player.inventoryrow1)
                            inventory.setrow2(player.inventoryrow2)
                        elif playerflag == 2:
                            inventory.setrow1(player2.inventoryrow1)
                            inventory.setrow2(player2.inventoryrow2)
                            
                        #inventory = self.taskbar.doopeninventory(font3)
                        flag = 0
                        #inventory = Inventory(font3)
    
                        if self.inventorykey1 == 1:
                            inventory.addkey()
		
			##if Scrollinvisibility(0,0,0,0,"1","1").readkeys(None):
                        ##    inventory.additem(Inventoryscrollinvisibility())

			if self.inventorymasterkey == 1:
                       		1###FIX for key in inventory.additem(Inventorymasterkey())
                        if self.inventorykey1 == 1:
                       		1###FIX for key in inventory.additem(Inventorykey1())
                       	if self.inventorykey2 == 1:
                       		1###FIX for key in inventory
			while flag == 0:#NOTE1
                            inventory.draw(screen)
                            pygame.display.update()
                            pygame.key.set_repeat(1000,1000)
                            for event in pygame.event.get():
                                if event.type == QUIT:
                                    return

                                if event.type == pygame.MOUSEBUTTONDOWN:###FIX UP is for inventory opening
                                    flag = 1
                                    self.inventoryitem = inventory.getitem(self.inventoryitem)
                                    pygame.key.set_repeat(1,1)
                                    print 'item = %s' % self.inventoryitem

                                elif event.type == KEYDOWN:
                                    if event.key == K_LEFT:
                                        inventory.moveleft()
                                    elif event.key == K_RIGHT:
                                        inventory.moveright()
                                    elif event.key == K_x:
                                        self.inventoryitem = inventory.getitem(self.inventoryitem)
                                        pygame.key.set_repeat(1,1)
                                        flag = 1


                                

                if event.type == pygame.MOUSEBUTTONUP:

                    position2 = pygame.mouse.get_pos()
                    self.position2ndx = position2[0]
                    self.position2ndy = position2[1]
                    
                    self.position1stx = 0
                    self.position1sty = 0
                    self.position2ndx = 0
                    self.position2ndy = 0
                    self.positionmovex = 0
                    self.positionmovey = 0

                    
                    
                if event.type == pygame.MOUSEMOTION:
                    positionmove = pygame.mouse.get_pos()
                    self.positionmovex = positionmove[0]-self.position1stx
                    self.positionmovey = positionmove[1]-self.position1sty
                    #print 'pos=%d' % positionmove[0]


                    
                    ##FIXME righclick end
                    self.position1stx = 0
                    self.position1sty = 0
                    self.position2ndx = 0
                    self.position2ndy = 0
                    self.positionmovex = 0
                    self.positionmovey = 0
                    
                elif event.type == KEYDOWN:
            	    
                    # player 1 key controls
                    player.draw(screen)
                    if player2:
                        player2.draw(screen)
                    if event.key == K_x:
                        if self.room.collide(player) == 2:
                            self.talkerlist = self.room.talkto() # FIX
                        if player2:
                            if self.room.collide(player2) == 2:
                                self.talkerlist = self.room.talkto()
                                print "self.talker=%s" % self.talkerlist[1]
			####if self.talkerlist == None:
                        #id = player.pickup(self.room)
			#if id == 3:
		        #       	self.taskbar.setdungeonkey1()
			#if id == 5:
		        #       	self.taskbar.setrubysword()
			#	player.setrubysword()
                    elif event.key == K_z:
                        player.fight(self.room)
                        if player2:
                            player2.fight(self.room)  
                    elif event.key == K_UP:
                        self.room.movedown()    
                    elif event.key == K_DOWN:
                        self.room.moveup()    
                    elif event.key == K_LEFT:
                        self.room.moveright()    
                    elif event.key == K_RIGHT:
                        self.room.moveleft()    
                    elif event.key == K_SPACE:
                        self.room.gameobjects.append(Bomb(player.x-self.room.relativex,player.y-self.room.relativey))
    
                    elif event.key == K_i:
#                        self.level.gameover = 1
                      #FIXME  pygame.event.flush()
                        flag = 0
                        inventory = Inventory(font3)
    
                        if self.inventorykey1 == 1:
                            inventory.addkey()
		
			##if Scrollinvisibility(0,0,0,0,"1","1").readkeys(None):
                        ##    inventory.additem(Inventoryscrollinvisibility())

			if self.inventorymasterkey == 1:
                       		1###FIX for key in inventory.additem(Inventorymasterkey())
                        if self.inventorykey1 == 1:
                       		1###FIX for key in inventory.additem(Inventorykey1())
                       	if self.inventorykey2 == 1:
                       		1###FIX for key in inventory
			while flag == 0:#NOTE1
                            pygame.key.set_repeat(1000,1000)
                            for event in pygame.event.get():
                                if event.type == QUIT:
                                    return

                                elif event.type == KEYDOWN:
                                    if event.key == K_LEFT:
                                        inventory.moveleft()
                                    elif event.key == K_RIGHT:
                                        inventory.moveright()
                                    elif event.key == K_x:
                                        self.inventoryitem = inventory.getitem(self.inventoryitem)
                                        pygame.key.set_repeat(1,1)
                                        flag = 1


                                inventory.draw(screen)
                                pygame.display.update()
            
	    pickupid = self.room.pickup(player)
	    #print "pickup=%s" % pickupid
	    if pickupid:
		if pickupid == 1: # NOTE : masterkey id
		    self.inventorymasterkey = 1
		elif pickupid == 2: ## NOTE: dungeonentrance 2 id opens with key 1
                    if self.inventorykey1 == 1:
                        self.room.removeentrance2()
                elif pickupid == 3: # NOTE dungeon key 1 id
                    flag = 0
                    self.inventorykey1 = 1
                    pygame.key.set_repeat(1000,1000)
                    self.room.draw(screen,player) 
                    player.drawstatic(screen)
                    if player2:
                        player2.drawstatic(screen)
                    screen.blit(font2.render("You picked up a key.", 6, (0,0,200)), (100,100))
                    pygame.display.update()
                    while flag == 0:#NOTE1
                            for event in pygame.event.get():
                                if event.type == QUIT:
                                    return

                                elif event.type == KEYDOWN:
                                    if event.key == K_x:
                                        pygame.key.set_repeat(1,1)
                                        flag = 1
                                     
                    self.inventorykey1 = 1
                elif pickupid == 4: # NOTE dungeon key 2 id
                    self.inventorykey2 = 1
                elif pickupid == 5: # NOTE ruby sword id
                    self.inventoryrubysword = 1
                    self.taskbar.setrubysword()

            if player2:
                pickupid = self.room.pickup(player2)
                #print "pickup=%s" % pickupid
                if pickupid:
                    if pickupid == 1: # NOTE : masterkey id
                        self.inventorymasterkey = 1
                    elif pickupid == 2: ## NOTE: dungeonentrance 2 id opens with key 1
                        if self.inventorykey1 == 1:
                            self.room.removeentrance2()
                    elif pickupid == 3: # NOTE dungeon key 1 id
                        flag = 0
                        self.inventorykey1 = 1
                        pygame.key.set_repeat(1000,1000)
                        self.room.draw(screen,player)
                        player.drawstatic(screen)
                        if player2:
                            player2.drawstatic(screen)
                        screen.blit(font2.render("You picked up a key.", 6, (0,0,200)), (100,100))
                        pygame.display.update()
                        while flag == 0:#NOTE1
                                for event in pygame.event.get():
                                    if event.type == QUIT:
                                        return
                                    if event.type == MOUSEBUTTONDOWN:
                                        pygame.key.set_repeat(1,1)
                                        flag = 1
                                    elif event.type == KEYDOWN:
                                        if event.key == K_x:
                                            pygame.key.set_repeat(1,1)
                                            flag = 1
                                         
                        self.inventorykey1 = 1
                    elif pickupid == 4: # NOTE dungeon key 2 id
                        self.inventorykey2 = 1
                    elif pickupid == 5: # NOTE ruby sword id
                        self.inventoryrubysword = 1
                        self.taskbar.setrubysword()

	    # FIXME player 2
            if (self.room.collide(player) == 1 or player.hitpoints <= 0) and (player2 and player2.hitpoints <= 0): # NOTE: return 1 after player heartmeter runs out (player.hit)
                endingimage = pygame.image.load('./pics/endingscreen.bmp').convert()
                while gameover == 0:
                        pygame.display.update()
                        screen.blit(endingimage, (0,0))
                        for event in pygame.event.get():
                                if event.type == QUIT:
                                        return
                                elif event.type == KEYDOWN:
                                        gameover = 1
                                        return
                                if event.type == pygame.MOUSEBUTTONDOWN:
                                        gameover = 1
                                        return
            ###if self.room.collide(player) == 3:###Dungeon wall
                ##self.room.undomove()
            ###    self.room.removeentrance2()
            self.room.update(player)
            self.room.draw(screen,player) 
            player.drawstatic(screen)
            if player2:
                player2.drawstatic(screen)

            for o in self.room.gameobjects:
                if o:
                    if randint(0,1) == 0:
                        o.fight(self.room,player)
                    else:
                        o.fight(self.room,player2)
                    if o.hitpoints <= 0:
                        self.room.removeobject(o)
	    sleep(0.2)
            # fight for enemies
            # remove dead game objects

	    ### Set player hitpoints in life bar
	    heartmeter.index = player.hitpoints
	    if player2:
                heartmeter2.index = player2.hitpoints

            for o in self.room.gameobjects:
                if o:
                    o.fight(self.room,player)
                    if o.hitpoints <= 0:
                        self.room.removeobject(o)

            if self.talkerlist != None:
                for o in self.talkerlist:
                    if o != None:
                        o.talk(screen,font)

            if self.position1stx != 0 or self.position1sty != 0:
                pygame.draw.rect(screen, (255,0,0), ((self.position1stx,self.position1sty),(self.positionmovex,self.positionmovey)),1)
                # collide with selection rectangle, this method is also in MOUSEBUTTONUP
                if self.collidewithrect(player,self.room,self.position1stx,self.position1sty,self.positionmovex,self.positionmovey):
                    print 'highlight'
                    player.highlight()
                    self.taskbar.highlight()
                if player2:
                    if self.collidewithrect(player2,self.room,self.position1stx,self.position1sty,self.positionmovex,self.positionmovey):
                        print 'highlight'
                        player2.highlight()
                        # FIXME player 2
                        self.taskbar.highlight()

            position = pygame.mouse.get_pos()
            positionx = position[0]
            positiony = position[1]
            ### move of player FIXME
            if positionx < 40:
                self.room.moveright()
                player.x += 10
                if player2:
                    player2.x += 10
            if positionx > 600:
                self.room.moveleft()
                player.x -= 10
                if player2:
                    player2.x -= 10
            if positiony < 40:
                self.room.movedown()
                player.y += 10
                if player2:
                    player2.y += 10
            if positiony > 360 and positiony < 400:
                self.room.moveup()
                player.y -= 10
                if player2:
                    player2.y -= 10
                
            self.taskbar.draw()
            heartmeter.draw(screen)
            if player2:
                heartmeter2.draw(screen)
            
            pygame.display.update()
            screen.blit(blankimage, (0,0))
            roomnumber = self.room.exit(self)
            self.chooseroom(roomnumber,font)


    def sethitf(self, hitf):
        for i in self.room.gameobjects:
            i.hitf = hitf

    def setxy(self,xx,yy):
        self.x = xx
        self.y = yy

    def chooseroom(self, roomnumber,font):
        if (roomnumber == 0):
            return
        # NOTE: 1_X  woods around haunted castle
        elif (roomnumber == 1):
            self.talker = None
            self.room = Maproom1(self.x,self.y)
        elif (roomnumber == 1.1):
            self.talker = None
            self.room = Maproom1_1(self.x,self.y)
        elif (roomnumber == 1.2):
            self.talker = None
            self.room = Maproom1_2(self.x,self.y)
        elif (roomnumber == 1.3):
            self.talker = None
            self.room = Maproominn1_3(self.x,self.y)
        elif (roomnumber == 1.4):
            self.talker = None
            self.room = Maproominn1_4(self.x,self.y)
        elif (roomnumber == 1.5):
            self.talker = None
            self.room = Maproominn1_5(self.x,self.y)
        elif (roomnumber == 1.6):
            self.talker = None
            self.room = Maproominn1_6(self.x,self.y)
        # NOTE left woods of haunted castle
        elif (roomnumber == "1.1.1"):
            self.talker = None
            self.room = Maproom1_1_1(self.x,self.y)
        # rooms of haunted castle    
        elif (roomnumber == 2):
            self.talker = None
            self.room = Maproom2(self.x,self.y)
        elif (roomnumber == 3):
            self.talker = None
            self.room = Maproom3(self.x,self.y)
        elif (roomnumber == 4):
            self.talker = None
            self.room = Maproom4(self.x,self.y)
        elif (roomnumber == 5):
            self.talker = None
            self.room = Maproom5(self.x,self.y)
        elif (roomnumber == 6):
            self.talker = None
            self.room = Maproom6(self.x,self.y)
        elif (roomnumber == 7):
            self.talker = None
            self.room = Maproom7(self.x,self.y)
        elif (roomnumber == 8):
            self.talker = None
            self.room = Maproom8(self.x,self.y)
        elif (roomnumber == 9):
            self.talker = None
            self.room = Maproom9(self.x,self.y)
        elif (roomnumber == 10):
            self.talker = None
            self.room = Maproom10(self.x,self.y)
        elif (roomnumber == 11):
            self.talker = None
            self.room = Maproom11(self.x,self.y)
        elif (roomnumber == 12):
            self.talker = None
            self.room = Maproom12(self.x,self.y)
        elif (roomnumber == 13):
            self.talker = None
            self.room = Maproom13(self.x,self.y)
        elif (roomnumber == 14):
            self.talker = None
            self.room = Maproom14(self.x,self.y)
        # set sword parameters
        if self.inventoryrubysword:
            self.sethitf(self.room.gameobjects.hit2)

        # collide with selection rectangle
    def collidewithrect(self, player,room,xx,yy,ww,hh):
            # FIX BUG
            #print 'rect x=%d y=%d player x=%d y=%d' % (self.x,self.y,player.x-room.relativex,player.y-room.relativey)
        #print 'rect x=%d y=%d player x=%d y=%d' % (xx,yy,player.x,player.y)
        if (player.x > xx  and 
            player.x < xx+ww and 
            player.y > yy and 
            player.y < yy + hh):
	    print "collision with Rect!"
            return 1 
        else:
            return 0

    def collidewithclick(self, player,room,xx,yy,ww,hh):
            # FIX BUG
            #print 'rect x=%d y=%d player x=%d y=%d' % (self.x,self.y,player.x-room.relativex,player.y-room.relativey)
        #print 'rect x=%d y=%d player x=%d y=%d' % (xx,yy,player.x,player.y)
        if (player.x+player.w > xx  and 
            player.x < xx+ww and 
            player.y+player.h > yy and 
            player.y < yy + hh):
	    print "collision with ClickRect!"
            return 1 
        else:
            return 0 

            
if __name__ == "__main__":
    foo = Game()




# Copyright (C) Johan Ceuppens 2010
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


import pygame
from pygame.locals import *
from gameobject import *
from stateimagelibrary import *
import random

class Ghost1(Gameobject):
    "Ghost1"
    def __init__(self,xx,yy):
	Gameobject.__init__(self, xx, yy)
        self.w = 36
        self.h = 36 
	self.stimlibleft = Stateimagelibrary()	
	self.stimlibright = Stateimagelibrary()	
        image = pygame.image.load('./pics/ghostleft1-36x36.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)	
        image = pygame.image.load('./pics/ghostleft1-36x36.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)	
        image = pygame.image.load('./pics/ghostleft1-36x36.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)	
        image = pygame.image.load('./pics/ghostleft1-36x36.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)	
        image = pygame.image.load('./pics/ghostleft2-36x36.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)	
        image = pygame.image.load('./pics/ghostleft2-36x36.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)	
        image = pygame.image.load('./pics/ghostleft2-36x36.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)	
        image = pygame.image.load('./pics/ghostleft2-36x36.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)	
        image = pygame.image.load('./pics/ghostleft1-36x36.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)	
        image = pygame.image.load('./pics/ghostleft1-36x36.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)	
        image = pygame.image.load('./pics/ghostleft1-36x36.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)	
        image = pygame.image.load('./pics/ghostleft1-36x36.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)	
        image = pygame.image.load('./pics/ghostleft2-36x36.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)	
        image = pygame.image.load('./pics/ghostleft2-36x36.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)	
        image = pygame.image.load('./pics/ghostleft2-36x36.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)	
        image = pygame.image.load('./pics/ghostleft2-36x36.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)	

        image = pygame.image.load('./pics/ghost1-36x36.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibright.addpicture(image)	
        image = pygame.image.load('./pics/ghost1-36x36.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibright.addpicture(image)	
        image = pygame.image.load('./pics/ghost1-36x36.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibright.addpicture(image)	
        image = pygame.image.load('./pics/ghost1-36x36.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibright.addpicture(image)	
        image = pygame.image.load('./pics/ghost2-36x36.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibright.addpicture(image)	
        image = pygame.image.load('./pics/ghost2-36x36.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibright.addpicture(image)	
        image = pygame.image.load('./pics/ghost2-36x36.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibright.addpicture(image)	
        image = pygame.image.load('./pics/ghost2-36x36.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibright.addpicture(image)	
        image = pygame.image.load('./pics/ghost1-36x36.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibright.addpicture(image)	
        image = pygame.image.load('./pics/ghost1-36x36.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibright.addpicture(image)	
        image = pygame.image.load('./pics/ghost1-36x36.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibright.addpicture(image)	
        image = pygame.image.load('./pics/ghost1-36x36.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibright.addpicture(image)	
        image = pygame.image.load('./pics/ghost2-36x36.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibright.addpicture(image)	
        image = pygame.image.load('./pics/ghost2-36x36.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibright.addpicture(image)	
        image = pygame.image.load('./pics/ghost2-36x36.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibright.addpicture(image)	
        image = pygame.image.load('./pics/ghost2-36x36.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibright.addpicture(image)	

	self.direction = "left"

    def draw(self, screen, room):
	if (self.direction == "left"):
            self.stimlibleft.draw(screen, self.x+room.relativex,self.y+room.relativey)
	elif (self.direction == "right"):
            self.stimlibright.draw(screen, self.x+room.relativex,self.y+room.relativey)
	    
	     
    def update(self,room):
	if (not self.collideobjectX(room)): 
	    if (self.direction == "left"):
	        self.x +=2
	        self.direction = "right" 
	    elif (self.direction == "right"):
	        self.x -=2
	        self.direction = "left"


	if (self.direction == "left"):
	        self.x -=1 
	elif (self.direction == "right"):
	        self.x +=1

    def collide(self, room, player):
	if (player.x > self.x+room.relativex  and 
	player.x < self.x+room.relativex+self.w and 
	player.y > self.y+room.relativey and 
	player.y < self.y+room.relativey + self.h):
	    print "collision with Ghost 1!"
	    if player.hit():
		return 1 
	    else:
	    	return 2 
	else:
	    return 0

		 

# Copyright (C) Johan Ceuppens 2011
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


import pygame
from pygame.locals import *
from gameobject import *
from stateimagelibrary import *
import random
from math import *
from time import *

class Ghostcircling(Gameobject):
    "ghostcircling"
    def __init__(self,xx,yy):
	Gameobject.__init__(self, xx, yy)
	self.i = 0 ## / medridians, / paralells
	self.j = 0###-2*3.14 ## / medridians, / paralells
        self.w = 36
        self.h = 36 
	self.stimlibleft = Stateimagelibrary()	
	self.stimlibright = Stateimagelibrary()	
        image = pygame.image.load('./pics/ghostwanderingleft2-36x36.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)	
        image = pygame.image.load('./pics/ghostwanderingleft2-36x36.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)	
        image = pygame.image.load('./pics/ghostwanderingleft2-36x36.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)	
        image = pygame.image.load('./pics/ghostwanderingleft2-36x36.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)	
        image = pygame.image.load('./pics/ghostwanderingleft2-36x36.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)	
        image = pygame.image.load('./pics/ghostwanderingleft2-36x36.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)	
        image = pygame.image.load('./pics/ghostwanderingleft2-36x36.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)	
        image = pygame.image.load('./pics/ghostwanderingleft2-36x36.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)	

        image = pygame.image.load('./pics/ghostwandering2-36x36.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibright.addpicture(image)	
        image = pygame.image.load('./pics/ghostwandering2-36x36.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibright.addpicture(image)	
        image = pygame.image.load('./pics/ghostwandering2-36x36.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibright.addpicture(image)	
        image = pygame.image.load('./pics/ghostwandering2-36x36.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibright.addpicture(image)	
        image.set_colorkey((0,0,0)) 
	self.stimlibright.addpicture(image)	
        image = pygame.image.load('./pics/ghostwandering2-36x36.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibright.addpicture(image)	
        image = pygame.image.load('./pics/ghostwandering2-36x36.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibright.addpicture(image)	
        image = pygame.image.load('./pics/ghostwandering2-36x36.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibright.addpicture(image)	
        image = pygame.image.load('./pics/ghostwandering2-36x36.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibright.addpicture(image)	

	self.direction = "left"

###    def draw(self, screen, room):
###	if (self.direction == "left"):
###            self.stimlibleft.draw(screen, self.x+room.relativex,self.y+room.relativey)
###	elif (self.direction == "right"):
###            self.stimlibright.draw(screen, self.x+room.relativex,self.y+room.relativey)
	    
	     
    def update(self,room):
	1

    def collide(self, room, player):
	if (player.x > self.x+room.relativex  and 
	player.x < self.x+room.relativex+self.w and 
	player.y > self.y+room.relativey and 
	player.y < self.y+room.relativey + self.h):
	    print "collision with ghostwandering2!"
	    if player.hit():
		return 1 
	    else:
	    	return 2 
	else:
	    return 0

    def draw(self,screen,room):
	color = (255,0,0)
	self.PI = 3.14152829
	self.cx = 150
	self.cy = 60 
	self.cz = 100
	self.n = 100
	self.r = 100
	if self.j < self.n / 2:
		self.theta1 = self.j*2*self.PI / self.n - self.PI
		self.theta2 = (self.j+1)*2*self.PI / self.n - self.PI
		if self.i < self.n:
			self.theta3 = self.i * 2*self.PI / self.n
			x = cos(self.theta2)*cos(self.theta3) 
			y = sin(self.theta2)*sin(self.theta3)
			z = sin(self.theta2)
			self.x = x * self.r
			self.y = y * self.r
			###self.z *= self.r
		        self.stimlibleft.draw(screen, self.cx+self.x+room.relativex,self.cy+self.y+room.relativey)
                        sleep(.05) # FIX ghost2 sleep
			###pygame.draw.line(pygame.display.get_surface(),color, (self.cx+self.x,self.cy+self.y),(self.cx+self.x,self.cy+self.y))
			self.i += .5 # FIX .001 
		else:
			self.i = 0
		self.j += .1
	else:
		self.j = 0

		 

# Copyright (C) Johan Ceuppens 2010
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


import pygame
from pygame.locals import *
from gameobject import *
from stateimagelibrary import *
import random

class GhostWandering(Gameobject):
    "Wandering Ghost"
    def __init__(self,xx,yy):
	Gameobject.__init__(self, xx, yy)
        self.w = 36
        self.h = 36 
	self.stimlibleft = Stateimagelibrary()	
	self.stimlibright = Stateimagelibrary()	
        image = pygame.image.load('./pics/ghostwanderingleft1-36x36.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)	
        image = pygame.image.load('./pics/ghostwanderingleft1-36x36.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)	
        image = pygame.image.load('./pics/ghostwanderingleft1-36x36.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)	
        image = pygame.image.load('./pics/ghostwanderingleft1-36x36.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)	
        image = pygame.image.load('./pics/ghostwanderingleft1-36x36.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)	
        image = pygame.image.load('./pics/ghostwanderingleft2-36x36.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)	
        image = pygame.image.load('./pics/ghostwanderingleft2-36x36.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)	
        image = pygame.image.load('./pics/ghostwanderingleft2-36x36.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)	
        image = pygame.image.load('./pics/ghostwanderingleft3-36x36.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)	
        image = pygame.image.load('./pics/ghostwanderingleft3-36x36.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)	
        image = pygame.image.load('./pics/ghostwanderingleft3-36x36.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)	
        image = pygame.image.load('./pics/ghostwanderingleft3-36x36.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)	
        image = pygame.image.load('./pics/ghostwanderingleft2-36x36.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)	
        image = pygame.image.load('./pics/ghostwanderingleft2-36x36.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)	
        image = pygame.image.load('./pics/ghostwanderingleft2-36x36.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)	
        image = pygame.image.load('./pics/ghostwanderingleft2-36x36.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)	

        image = pygame.image.load('./pics/ghostwandering1-36x36.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibright.addpicture(image)	
        image = pygame.image.load('./pics/ghostwandering1-36x36.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibright.addpicture(image)	
        image = pygame.image.load('./pics/ghostwandering1-36x36.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibright.addpicture(image)	
        image = pygame.image.load('./pics/ghostwandering1-36x36.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibright.addpicture(image)	
        image = pygame.image.load('./pics/ghostwandering2-36x36.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibright.addpicture(image)	
        image = pygame.image.load('./pics/ghostwandering2-36x36.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibright.addpicture(image)	
        image = pygame.image.load('./pics/ghostwandering2-36x36.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibright.addpicture(image)	
        image = pygame.image.load('./pics/ghostwandering2-36x36.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibright.addpicture(image)	
        image = pygame.image.load('./pics/ghostwandering3-36x36.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibright.addpicture(image)	
        image = pygame.image.load('./pics/ghostwandering3-36x36.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibright.addpicture(image)	
        image = pygame.image.load('./pics/ghostwandering3-36x36.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibright.addpicture(image)	
        image = pygame.image.load('./pics/ghostwandering3-36x36.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibright.addpicture(image)	
        image = pygame.image.load('./pics/ghostwandering2-36x36.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibright.addpicture(image)	
        image = pygame.image.load('./pics/ghostwandering2-36x36.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibright.addpicture(image)	
        image = pygame.image.load('./pics/ghostwandering2-36x36.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibright.addpicture(image)	
        image = pygame.image.load('./pics/ghostwandering2-36x36.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibright.addpicture(image)	

	self.direction = "left"

    def draw(self, screen, room):
	if (self.direction == "left"):
            self.stimlibleft.draw(screen, self.x+room.relativex,self.y+room.relativey)
	elif (self.direction == "right"):
            self.stimlibright.draw(screen, self.x+room.relativex,self.y+room.relativey)
	    
	     
    def update(self,room):
	if (not self.collideobjectX(room)): 
	    if (self.direction == "left"):
	        self.x +=2
	        self.direction = "right" 
	    elif (self.direction == "right"):
	        self.x -=2
	        self.direction = "left"


	if (self.direction == "left"):
	        self.x -=1 
	elif (self.direction == "right"):
	        self.x +=1

    def collide(self, room, player):
	if (player.x > self.x+room.relativex  and 
	player.x < self.x+room.relativex+self.w and 
	player.y > self.y+room.relativey and 
	player.y < self.y+room.relativey + self.h):
	    print "collision with ghostwandering 1!"
	    if player.hit():
		return 1 
	    else:
	    	return 2 
	else:
	    return 0

		 

# Copyright (C) Johan Ceuppens 2010
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


import pygame
from pygame.locals import *
from gameobject import *
from stateimagelibrary import *
import random
from time import *

class Goblin1(Gameobject):
    "Goblin"
    def __init__(self,xx,yy):
	Gameobject.__init__(self, xx, yy)
        self.w = 48
        self.h = 48

        self.hitpoints = 3
        
	self.stimlibdown = Stateimagelibrary()	
	self.stimlibup = Stateimagelibrary()	
        image = pygame.image.load('./pics/goblin1-48x48.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibdown.addpicture(image)	
        image = pygame.image.load('./pics/goblin1-48x48.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibdown.addpicture(image)
	image = pygame.image.load('./pics/goblin1-48x48.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibdown.addpicture(image)
	image = pygame.image.load('./pics/goblin1-48x48.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibdown.addpicture(image)

	image = pygame.image.load('./pics/goblin2-48x48.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibdown.addpicture(image)	
        image = pygame.image.load('./pics/goblin2-48x48.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibdown.addpicture(image)
	image = pygame.image.load('./pics/goblin2-48x48.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibdown.addpicture(image)
	image = pygame.image.load('./pics/goblin2-48x48.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibdown.addpicture(image)

        image = pygame.image.load('./pics/goblin1-48x48.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibdown.addpicture(image)	
        image = pygame.image.load('./pics/goblin1-48x48.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibdown.addpicture(image)
	image = pygame.image.load('./pics/goblin1-48x48.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibdown.addpicture(image)
	image = pygame.image.load('./pics/goblin1-48x48.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibdown.addpicture(image)
	
        image = pygame.image.load('./pics/goblin3-48x48.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibdown.addpicture(image)	
        image = pygame.image.load('./pics/goblin3-48x48.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibdown.addpicture(image)
	image = pygame.image.load('./pics/goblin3-48x48.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibdown.addpicture(image)
	image = pygame.image.load('./pics/goblin3-48x48.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibdown.addpicture(image)

        image = pygame.image.load('./pics/goblin2-48x48.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibdown.addpicture(image)	
        image = pygame.image.load('./pics/goblin2-48x48.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibdown.addpicture(image)
	image = pygame.image.load('./pics/goblin2-48x48.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibdown.addpicture(image)
	image = pygame.image.load('./pics/goblin2-48x48.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibdown.addpicture(image)

        image = pygame.image.load('./pics/goblinup1-48x48.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibup.addpicture(image)
	image = pygame.image.load('./pics/goblinup1-48x48.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibup.addpicture(image)
	image = pygame.image.load('./pics/goblinup1-48x48.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibup.addpicture(image)
	image = pygame.image.load('./pics/goblinup1-48x48.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibup.addpicture(image)

	image = pygame.image.load('./pics/goblinup2-48x48.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibup.addpicture(image)
	image = pygame.image.load('./pics/goblinup2-48x48.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibup.addpicture(image)
	image = pygame.image.load('./pics/goblinup2-48x48.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibup.addpicture(image)
	image = pygame.image.load('./pics/goblinup2-48x48.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibup.addpicture(image)

	image = pygame.image.load('./pics/goblinup3-48x48.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibup.addpicture(image)
	image = pygame.image.load('./pics/goblinup3-48x48.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibup.addpicture(image)
	image = pygame.image.load('./pics/goblinup3-48x48.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibup.addpicture(image)
	image = pygame.image.load('./pics/goblinup3-48x48.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibup.addpicture(image)
        	
        image = pygame.image.load('./pics/goblinup2-48x48.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibup.addpicture(image)
	image = pygame.image.load('./pics/goblinup2-48x48.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibup.addpicture(image)
	image = pygame.image.load('./pics/goblinup2-48x48.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibup.addpicture(image)
	image = pygame.image.load('./pics/goblinup2-48x48.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibup.addpicture(image)

	self.talkcounter = 0
	self.direction = "down"

    def draw(self, screen, room):
	if (self.direction == "down"):
            self.stimlibdown.draw(screen, self.x+room.relativex,self.y+room.relativey)
	elif (self.direction == "up"):
            self.stimlibup.draw(screen, self.x+room.relativex,self.y+room.relativey)
	    
	     
    def update(self,room):
        sleep(.04) # FIX goblin sleep
	
	if (not self.collideobjectY(room)): 
	    if (self.direction == "down"):
	        self.y -=2
	        self.direction = "up" 
	    elif (self.direction == "up"):
	        self.y +=2
	        self.direction = "down"

	if (self.direction == "up"):
	        self.y -=1 
	elif (self.direction == "down"):
	        self.y +=1

    def collide(self, room, player):
        # FIX BUG
        print 'goblin x=%d y=%d player x=%d y=%d' % (self.x,self.y,player.x-room.relativex,player.y)
	if (player.x-room.relativex > self.x  and 
	player.x-room.relativex < self.x+self.w and 
	player.y-room.relativey > self.y and 
	player.y-room.relativey < self.y + self.h):
	    print "collision with Goblin!"
	    return 1 
	else:
	    return 0 ## for game self.talker

# Copyright (C) Johan Ceuppens 2010
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


import pygame
from pygame.locals import *
from gameobject import *
from stateimagelibrary import *
import random
from rng import *
from time import *

class Goblin2(Gameobject):
    "Goblin"
    def __init__(self,xx,yy):
	Gameobject.__init__(self, xx, yy)
        self.w = 48
        self.h = 48

        self.hitpoints = 3
        
	self.stimlibleft = Stateimagelibrary()	
	self.stimlibright = Stateimagelibrary()	
        image = pygame.image.load('./pics/goblin2left1-48x48.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)	
        image = pygame.image.load('./pics/goblin2left2-48x48.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)
        image = pygame.image.load('./pics/goblin2right1-48x48.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibright.addpicture(image)	
        image = pygame.image.load('./pics/goblin2right2-48x48.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibright.addpicture(image)

	self.talkcounter = 0
	self.direction = "left"

    def draw(self, screen, room):
	if (self.direction == "left"):
            self.stimlibleft.draw(screen, self.x+room.relativex,self.y+room.relativey)
	elif (self.direction == "right"):
            self.stimlibright.draw(screen, self.x+room.relativex,self.y+room.relativey)
	    
	     
    def update(self,room,player):
        sleep(.04) # FIX goblin sleep
#	if (not self.collideobjectY(room)): 
#	    if (self.direction == "right"):
#	        self.x -=2
#	        self.direction = "left" 
#	    elif (self.direction == "left"):
#	        self.x +=2
#	        self.direction = "right"

	if player.x < self.x:
		self.x -= 2
	elif player.x > self.x+self.w:
		self.x += 2	
	if player.y < self.y:
		self.y -= 2
	elif player.y > self.y+self.h:
		self.y += 2	

	if (self.direction == "left"):
	        self.x -=2
	elif (self.direction == "right"):
	        self.x +=2

    def fight(self,room,player):
        self.fightcounter = 1
        #print 'fight'
        o = player.collidesword(room,self)
        #print 'fight %s' % o
        if o:
            print 'player is hit!'
            player.hitwithsword(RNG().rollgoblinknife())

# Copyright (C) Johan Ceuppens 2010
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


import pygame
from pygame.locals import *
from gameobject import *
from stateimagelibrary import *
import random
from rng import *
from time import *

class Goblin3(Gameobject):
    "Goblin"
    def __init__(self,xx,yy):
	Gameobject.__init__(self, xx, yy)
        self.w = 48
        self.h = 48

        self.hitpoints = 3
        
	self.stimlibleft = Stateimagelibrary()	
	self.stimlibright = Stateimagelibrary()	
	self.stimlibdown = Stateimagelibrary()	
	self.stimlibup = Stateimagelibrary()	
        image = pygame.image.load('./pics/goblin2left1-48x48.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibleft.addpicture(image)	
        image = pygame.image.load('./pics/goblin2left2-48x48.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibleft.addpicture(image)
        image = pygame.image.load('./pics/goblin2right1-48x48.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibright.addpicture(image)	
        image = pygame.image.load('./pics/goblin2right2-48x48.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibright.addpicture(image)
        image = pygame.image.load('./pics/goblin2right1-48x48.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibdown.addpicture(image)	
        image = pygame.image.load('./pics/goblin2right2-48x48.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibdown.addpicture(image)
        image = pygame.image.load('./pics/goblin2right1-48x48.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibup.addpicture(image)	
        image = pygame.image.load('./pics/goblin2right2-48x48.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibup.addpicture(image)

	self.talkcounter = 0
	self.direction = "left"

    def draw(self, screen, room):
	if (self.direction == "left"):
            self.stimlibleft.draw(screen, self.x+room.relativex,self.y+room.relativey)
	elif (self.direction == "right"):
            self.stimlibright.draw(screen, self.x+room.relativex,self.y+room.relativey)
	elif (self.direction == "down"):
            self.stimlibdown.draw(screen, self.x+room.relativex,self.y+room.relativey)
	elif (self.direction == "up"):
            self.stimlibup.draw(screen, self.x+room.relativex,self.y+room.relativey)
	    
	     
    def update(self,room,player):
        ###sleep(.04) # FIX goblin sleep
	if room.collidewithenemy(self):
	    if (self.direction == "right"):
	        self.x -=4
	        self.direction = "left" 
	    elif (self.direction == "left"):
	        self.x +=4
	        self.direction = "right"
	    elif (self.direction == "down"):
	        self.y -=4
	        self.direction = "up" 
	    elif (self.direction == "up"):
	        self.y +=4
	        self.direction = "down"

	if player.x+28-room.relativex < self.x:
		self.x -= 2
		self.direction = "left"
	if player.x-28-room.relativex > self.x:
		self.direction = "right"
		self.x += 2	
	if player.y+10-room.relativey < self.y:
		self.direction = "up"
		self.y -= 2
	if player.y-10-room.relativey > self.y:
		self.direction = "down"
		self.y += 2

    def collide(self, room, player):
        # FIX BUG
        #print 'gameobject x=%d y=%d player x=%d y=%d' % (self.x,self.y,player.x-room.relativex,player.y-room.relativey)
	if (player.x-room.relativex > self.x-self.w  and 
	player.x-room.relativex < self.x+self.w+self.w and 
	player.y-room.relativey > self.y-self.h and 
	player.y-room.relativey < self.y + self.h +self.h):
	    #print "collision with Game Object!"
	    return 1 
	else:
	    return 0 ## for game self.talker


    def fight(self,room,player):
        self.fightcounter = 1
        o = player.collidewithenemyweapon(room,self)
        if o:
            player.hitwithenemyweapon(RNG().rollgoblinknife())

# Copyright (C) Johan Ceuppens 2010
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


import pygame
from pygame.locals import *
from gameobject import *
from stateimagelibrary import *
import random
from time import *
from venomspit import *

class Gohma(Gameobject):
    "Gohma enemy"
    def __init__(self,xx,yy):
	Gameobject.__init__(self, xx, yy)
        self.w = 64
        self.h = 64 
	self.stimlibleft = Stateimagelibrary()	
	self.stimlibright = Stateimagelibrary()	
        image = pygame.image.load('./pics/gohma1.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/gohma1.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/gohma1.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/gohma1.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibleft.addpicture(image)
        image = pygame.image.load('./pics/gohma2.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/gohma2.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/gohma2.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/gohma2.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibleft.addpicture(image)
        image = pygame.image.load('./pics/gohma3.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/gohma3.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/gohma3.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/gohma3.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/gohma4.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/gohma4.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/gohma4.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/gohma4.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibleft.addpicture(image)

        image = pygame.image.load('./pics/gohma1.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibright.addpicture(image)
	image = pygame.image.load('./pics/gohma1.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibright.addpicture(image)
	image = pygame.image.load('./pics/gohma1.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibright.addpicture(image)
	image = pygame.image.load('./pics/gohma1.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibright.addpicture(image)
        image = pygame.image.load('./pics/gohma2.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibright.addpicture(image)
	image = pygame.image.load('./pics/gohma2.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibright.addpicture(image)
	image = pygame.image.load('./pics/gohma2.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibright.addpicture(image)
	image = pygame.image.load('./pics/gohma2.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibright.addpicture(image)
        image = pygame.image.load('./pics/gohma3.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibright.addpicture(image)
	image = pygame.image.load('./pics/gohma3.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibright.addpicture(image)
	image = pygame.image.load('./pics/gohma3.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibright.addpicture(image)
	image = pygame.image.load('./pics/gohma3.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibright.addpicture(image)
	image = pygame.image.load('./pics/gohma4.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibright.addpicture(image)
	image = pygame.image.load('./pics/gohma4.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibright.addpicture(image)
	image = pygame.image.load('./pics/gohma4.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibright.addpicture(image)
	image = pygame.image.load('./pics/gohma4.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibright.addpicture(image)

	self.direction = "left"

    def draw(self, screen, room):
	if (self.direction == "left"):
            self.stimlibleft.draw(screen, self.x+room.relativex,self.y+room.relativey)
	elif (self.direction == "right"):
            self.stimlibright.draw(screen, self.x+room.relativex,self.y+room.relativey)
	    
	     
    def update(self,room):
        sleep(.01) # FIX darkknight sleep
	if (random.randint(0,100) == 0 and self.direction == "left"):
	   self.direction = "right"
	elif (random.randint(0,100) == 0 and self.direction == "right"):
	   self.direction = "left"

	if (not self.collideobjectX(room)): 
	    if (self.direction == "left"):
	        self.x +=2
	        self.direction = "right" 
	    elif (self.direction == "right"):
	        self.x -=2
	        self.direction = "left"


	if (self.direction == "left"):
	        self.x -=1 
	elif (self.direction == "right"):
	        self.x +=1

        if random.randint(0,300) == 0:
            room.gameobjects.append(Venomspit(self.x+self.w/2,self.y+self.h))

    def collide(self, room, player):
	if (player.x > self.x+room.relativex  and 
	player.x < self.x+room.relativex+self.w and 
	player.y > self.y+room.relativey and 
	player.y < self.y+room.relativey + self.h):
	    print "collision with Gohma!"
	    if player.hit():
		return 1 
	    else:
	    	return 2 
	else:
	    return 0

		 

# Copyright (C) Johan Ceuppens 2010
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


import pygame
from pygame.locals import *
from gameobject import *
from stateimagelibrary import *
import random
from time import *
from venomspit import *

class GohmaRight(Gameobject):
    "Gohma enemy"
    def __init__(self,xx,yy):
	Gameobject.__init__(self, xx, yy)
        self.w = 64
        self.h = 64 
	self.stimlibleft = Stateimagelibrary()	
	self.stimlibright = Stateimagelibrary()	
        image = pygame.image.load('./pics/gohmaright1.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/gohmaright1.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/gohmaright1.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/gohmaright1.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibleft.addpicture(image)
        image = pygame.image.load('./pics/gohmaright2.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/gohmaright2.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/gohmaright2.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/gohmaright2.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibleft.addpicture(image)
        image = pygame.image.load('./pics/gohmaright3.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/gohmaright3.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/gohmaright3.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/gohmaright3.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/gohmaright4.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/gohmaright4.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/gohmaright4.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/gohmaright4.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibleft.addpicture(image)

        image = pygame.image.load('./pics/gohmaright1.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibright.addpicture(image)
	image = pygame.image.load('./pics/gohmaright1.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibright.addpicture(image)
	image = pygame.image.load('./pics/gohmaright1.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibright.addpicture(image)
	image = pygame.image.load('./pics/gohmaright1.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibright.addpicture(image)
        image = pygame.image.load('./pics/gohmaright2.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibright.addpicture(image)
	image = pygame.image.load('./pics/gohmaright2.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibright.addpicture(image)
	image = pygame.image.load('./pics/gohmaright2.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibright.addpicture(image)
	image = pygame.image.load('./pics/gohmaright2.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibright.addpicture(image)
        image = pygame.image.load('./pics/gohmaright3.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibright.addpicture(image)
	image = pygame.image.load('./pics/gohmaright3.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibright.addpicture(image)
	image = pygame.image.load('./pics/gohmaright3.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibright.addpicture(image)
	image = pygame.image.load('./pics/gohmaright3.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibright.addpicture(image)
	image = pygame.image.load('./pics/gohmaright4.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibright.addpicture(image)
	image = pygame.image.load('./pics/gohmaright4.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibright.addpicture(image)
	image = pygame.image.load('./pics/gohmaright4.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibright.addpicture(image)
	image = pygame.image.load('./pics/gohmaright4.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibright.addpicture(image)

	self.direction = "down"

    def draw(self, screen, room):
	if (self.direction == "down"):
            self.stimlibleft.draw(screen, self.x+room.relativex,self.y+room.relativey)
	elif (self.direction == "up"):
            self.stimlibright.draw(screen, self.x+room.relativex,self.y+room.relativey)
	    
	     
    def update(self,room):
        sleep(.01) # FIX darkknight sleep
##	if (random.randint(0,100) == 0 and self.direction == "up"):
##	   self.direction = "down"
##	elif (random.randint(0,100) == 0 and self.direction == "down"):
##	   self.direction = "up"

	if (self.collideobjectXY(room)): 
	    if (self.direction == "up"):
	        self.y +=2
	        self.direction = "down" 
	    elif (self.direction == "down"):
	        self.y -=2
	        self.direction = "up"


	if (self.direction == "up"):
	        self.y -=1 
	elif (self.direction == "down"):
	        self.y +=1

        #FIX gohma down spit venom if random.randint(0,300) == 0:
        #    room.gameobjects.append(Venomspit(self.x+self.w/2,self.y+self.h))

    def collide(self, room, player):
	if (player.x > self.x+room.relativex  and 
	player.x < self.x+room.relativex+self.w and 
	player.y > self.y+room.relativey and 
	player.y < self.y+room.relativey + self.h):
	    print "collision with gohmadown!"
	    if player.hit():
		return 1 
	    else:
	    	return 2 
	else:
	    return 0

		 

# Copyright (C) Johan Ceuppens 2010
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


import pygame
from pygame.locals import *
from gameobject import *
from stateimagelibrary import *
import random
from time import *
from venomspitup import *

class GohmaUp(Gameobject):
    "Gohma Up"
    def __init__(self,xx,yy):
	Gameobject.__init__(self, xx, yy)
        self.w = 64
        self.h = 64 
	self.stimlibleft = Stateimagelibrary()	
	self.stimlibright = Stateimagelibrary()	
        image = pygame.image.load('./pics/gohmaup1.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/gohmaup1.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/gohmaup1.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/gohmaup1.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibleft.addpicture(image)
        image = pygame.image.load('./pics/gohmaup2.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/gohmaup2.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/gohmaup2.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/gohmaup2.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibleft.addpicture(image)
        image = pygame.image.load('./pics/gohmaup3.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/gohmaup3.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/gohmaup3.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/gohmaup3.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/gohmaup4.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/gohmaup4.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/gohmaup4.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibleft.addpicture(image)
	image = pygame.image.load('./pics/gohmaup4.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibleft.addpicture(image)

        image = pygame.image.load('./pics/gohmaup1.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibright.addpicture(image)
	image = pygame.image.load('./pics/gohmaup1.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibright.addpicture(image)
	image = pygame.image.load('./pics/gohmaup1.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibright.addpicture(image)
	image = pygame.image.load('./pics/gohmaup1.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibright.addpicture(image)
        image = pygame.image.load('./pics/gohmaup2.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibright.addpicture(image)
	image = pygame.image.load('./pics/gohmaup2.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibright.addpicture(image)
	image = pygame.image.load('./pics/gohmaup2.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibright.addpicture(image)
	image = pygame.image.load('./pics/gohmaup2.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibright.addpicture(image)
        image = pygame.image.load('./pics/gohmaup3.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibright.addpicture(image)
	image = pygame.image.load('./pics/gohmaup3.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibright.addpicture(image)
	image = pygame.image.load('./pics/gohmaup3.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibright.addpicture(image)
	image = pygame.image.load('./pics/gohmaup3.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibright.addpicture(image)
	image = pygame.image.load('./pics/gohmaup4.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibright.addpicture(image)
	image = pygame.image.load('./pics/gohmaup4.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibright.addpicture(image)
	image = pygame.image.load('./pics/gohmaup4.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibright.addpicture(image)
	image = pygame.image.load('./pics/gohmaup4.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibright.addpicture(image)

	self.direction = "left"

    def draw(self, screen, room):
	if (self.direction == "left"):
            self.stimlibleft.draw(screen, self.x+room.relativex,self.y+room.relativey)
	elif (self.direction == "right"):
            self.stimlibright.draw(screen, self.x+room.relativex,self.y+room.relativey)
	    
	     
    def update(self,room):
        sleep(.01) # FIX gohma up sleep
	if (random.randint(0,100) == 0 and self.direction == "left"):
	   self.direction = "right"
	elif (random.randint(0,100) == 0 and self.direction == "right"):
	   self.direction = "left"

	if (not self.collideobjectX(room)): 
	    if (self.direction == "left"):
	        self.x +=2
	        self.direction = "right" 
	    elif (self.direction == "right"):
	        self.x -=2
	        self.direction = "left"


	if (self.direction == "left"):
	        self.x -=1 
	elif (self.direction == "right"):
	        self.x +=1

        if random.randint(0,300) == 0:
            room.gameobjects.append(VenomspitUp(self.x+self.w/2,self.y))

    def collide(self, room, player):
	if (player.x > self.x+room.relativex  and 
	player.x < self.x+room.relativex+self.w and 
	player.y > self.y+room.relativey and 
	player.y < self.y+room.relativey + self.h):
	    print "collision with Gohma up!"
	    if player.hit():
		return 1 
	    else:
	    	return 2 
	else:
	    return 0

		 

# Copyright (C) Johan Ceuppens 2010
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


import pygame
from pygame.locals import *
from meter import *

class Heart:
	def __init__(self):
        	self.image = pygame.image.load('./pics/life3.bmp').convert()
        	self.image.set_colorkey((0,0,0)) 
		

class HeartMeter(Meter):
    "life or mana meter"
    def __init__(self,x,y):
	Meter.__init__(self)
        self.x = x
        self.y = y
        
    def draw(self,screen):
	j = 0
	for i in range(0,self.index):
        	screen.blit(self.hearts[0].image, (self.x+j*1, self.y))
		j += 1

# Copyright (C) Johan Ceuppens 2010 
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


import pygame
from pygame.locals import *
from gameobject import *

class InnDoor(Gameobject):
    "Inn Door"
    def __init__(self, xx,yy):
        Gameobject.__init__(self,xx,yy)
        self.image = pygame.image.load('./pics/inndoor1-75x100.bmp').convert()
        self.image.set_colorkey((0,0,0)) 

    def collide(self, room, player):
	if (player.x > self.x+room.relativex  and 
	player.x < self.x+room.relativex+self.w and 
	player.y > self.y+room.relativey and 
	player.y < self.y+room.relativey + self.h):
	    print "collision in door!"
	    room.removeobject(self)#NOTE door opens (disappears)
	else:
	    return 0

# Copyright (C) Johan Ceuppens 2010
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


import pygame
from pygame.locals import *
from gameobject import *
from stateimagelibrary import *
import random
from time import *

class InnGuardian2(Gameobject):
    "Inn Guardian 2, left to right"
    def __init__(self,xx,yy):
	Gameobject.__init__(self, xx, yy)
        self.w = 48
        self.h = 48 
	self.stimlibleft = Stateimagelibrary()	
	self.stimlibright = Stateimagelibrary()	
        image = pygame.image.load('./pics/innguardian2.1-48x48.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibleft.addpicture(image)	
        image = pygame.image.load('./pics/innguardian2.2-48x48.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibleft.addpicture(image)	
        image = pygame.image.load('./pics/innguardian2.3-48x48.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibleft.addpicture(image)	

        image = pygame.image.load('./pics/innguardianright2.1-48x48.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibright.addpicture(image)	
        image = pygame.image.load('./pics/innguardianright2.2-48x48.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibright.addpicture(image)	
        image = pygame.image.load('./pics/innguardianright2.3-48x48.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibright.addpicture(image)	

	self.direction = "left"

    def draw(self, screen, room):
	if (self.direction == "left"):
            self.stimlibleft.draw(screen, self.x+room.relativex,self.y+room.relativey)
	elif (self.direction == "right"):
            self.stimlibright.draw(screen, self.x+room.relativex,self.y+room.relativey)
	    
	     
    def update(self,room):
        sleep(.05) # FIX darkkngith sleep
	if (random.randint(0,100) == 0 and self.direction == "left"):
	   self.direction = "right"
	elif (random.randint(0,100) == 0 and self.direction == "right"):
	   self.direction = "left"

	if (not self.collideobjectX(room)): 
	    if (self.direction == "left"):
	        self.x +=2
	        self.direction = "right" 
	    elif (self.direction == "right"):
	        self.x -=2
	        self.direction = "left"


	if (self.direction == "left"):
	        self.x -=1 
	elif (self.direction == "right"):
	        self.x +=1

    def collide(self, room, player):
	if (player.x > self.x+room.relativex  and 
	player.x < self.x+room.relativex+self.w and 
	player.y > self.y+room.relativey and 
	player.y < self.y+room.relativey + self.h):
	    print "collision with Inn Guardian 2!"
	    return 2 
	else:
	    return 0

    def talk(self, screen,font):
        if self.talkcounter == 0:
            return
        
        if self.talkcounter > 4:
                self.talkcounter = 0
                return 
        talkover = 0
        while talkover == 0:
            pygame.display.update()
            if self.talkcounter == 1:
                screen.blit(font.render("This is the Friendly Arm Inn.", 6, (255,255,255)), (10,100))
            elif self.talkcounter == 2:
                screen.blit(font.render("I am a guardian of the inn.", 6, (255,255,255)), (10,100))
            elif self.talkcounter == 3:
                screen.blit(font.render("The Innkeeper is named Yuan.", 6, (255,255,255)), (10,100))
            elif self.talkcounter == 4:
                screen.blit(font.render("Back in the day, he was a good warrior.", 6, (255,255,255)), (10,100))
            for event in pygame.event.get():
                if event.type == QUIT:
                    return
                elif event.type == KEYDOWN:
                    if event.key == K_z:
                        talkover = 1
                        self.talkcounter += 1
                	 

# Copyright (C) Johan Ceuppens 2010
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


import pygame
from pygame.locals import *
from gameobject import *
from stateimagelibrary import *
import random
from time import *
from innguardian2 import *

class InnGuardian3(InnGuardian2):
    "Inn Guardian 2, left to right"
    def __init__(self,xx,yy):
	InnGuardian2.__init__(self, xx, yy)
   
    def collide(self, room, player):
	if (player.x > self.x+room.relativex  and 
	player.x < self.x+room.relativex+self.w and 
	player.y > self.y+room.relativey and 
	player.y < self.y+room.relativey + self.h):
	    print "collision with Inn Guardian 3!"
	    return 2 
	else:
	    return 0

    def talk(self, screen,font):
        if self.talkcounter == 0:
            return
        
        if self.talkcounter > 3:
                self.talkcounter = 0
                return 
        talkover = 0
        while talkover == 0:
            pygame.display.update()
            if self.talkcounter == 1:
                screen.blit(font.render("This is the adventurer's hall.", 6, (255,255,255)), (10,100))
            elif self.talkcounter == 2:
                screen.blit(font.render("The guardians are all veteran warriors.", 6, (255,255,255)), (10,100))
            elif self.talkcounter == 3:
                screen.blit(font.render("We fought the Ratlins together with master Yuan.", 6, (255,255,255)), (10,100))
            for event in pygame.event.get():
                if event.type == QUIT:
                    return
                elif event.type == KEYDOWN:
                    if event.key == K_z:
                        talkover = 1
                        self.talkcounter += 1
                	 

# Copyright (C) Johan Ceuppens 2010
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


import pygame
from pygame.locals import *
from gameobject import *
from stateimagelibrary import *
import random
from time import *

class InnGuardian(Gameobject):
    ""
    def __init__(self,xx,yy):
	Gameobject.__init__(self, xx, yy)
        self.w = 48
        self.h = 48	
        self.image = pygame.image.load('./pics/innguardian1-48x48.bmp').convert()
        self.image.set_colorkey((0,0,255)) 
        self.talkcounter = 0
        
    def draw(self, screen, room):
        screen.blit(self.image, (self.x+room.relativex,self.y+room.relativey))
	    
	     
    def update(self,room):
        1

    def collide(self, room, player):
	if (player.x > self.x+room.relativex  and 
	player.x < self.x+room.relativex+self.w and 
	player.y > self.y+room.relativey and 
	player.y < self.y+room.relativey + self.h):
	    print "collision with Inn Guardian!"
	    return 2 
	else:
	    return 0
		 
    def talk(self, screen,font):
        if self.talkcounter == 0:
            return
        
        if self.talkcounter > 2:
                self.talkcounter = 0
                return 
        talkover = 0
        while talkover == 0:
            pygame.display.update()
            if self.talkcounter == 1:
                screen.blit(font.render("This is the Friendly Arm Inn.", 6, (255,255,255)), (10,100))
            elif self.talkcounter == 2:
                screen.blit(font.render("You may enter if you want.", 6, (255,255,255)), (10,100))
            for event in pygame.event.get():
                if event.type == QUIT:
                    return
                elif event.type == KEYDOWN:
                    if event.key == K_z:
                        talkover = 1
                        self.talkcounter += 1
                

# Copyright (C) Johan Ceuppens 2011
# Copyright (C) Johan Ceuppens 2010

# Copyright (C) Johan Ceuppens 2009 
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

import pygame
from pygame.locals import *

from inventoryitem import *

class Inventorybomb(Inventoryitem):
    def __init__(self):
        Inventoryitem.__init__(self, "./pics/bomb1.bmp")

    def use(self,e,game):
        print 'You used a bomb on %s' % e

# Copyright (C) Johan Ceuppens 2011
# Copyright (C) Johan Ceuppens 2010

# Copyright (C) Johan Ceuppens 2009 
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

import pygame
from pygame.locals import *

from inventoryitem import *

class Inventorydefaultsword(Inventoryitem):
    def __init__(self):
        Inventoryitem.__init__(self, './pics/taskbar-defaultsword1-32x32.bmp')

    def use(self,e,game):
        print 'You used a default sword on %s' % e

# Copyright (C) Johan Ceuppens 2011
# Copyright (C) Johan Ceuppens 2010

# Copyright (C) Johan Ceuppens 2009 
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

import pygame
from pygame.locals import *

from inventoryitem import *

class InventoryFairyTunic(Inventoryitem):
    def __init__(self):
        Inventoryitem.__init__(self, './pics/fairytunic1-48x48.bmp')

    def use(self,e,game):
        print 'You used a fairy tunic on %s' % e

# Copyright (C) Johan Ceuppens 2011
# Copyright (C) Johan Ceuppens 2010

# Copyright (C) Johan Ceuppens 2009 
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

import pygame
from pygame.locals import *


class Inventoryitem(object):
    def __init__(self,imagefilename):
        self.image = pygame.image.load(imagefilename).convert()
        self.image.set_colorkey((0,0,0))#FIXME rgb transdparency

    def draw(self,screen,x,y):
        screen.blit(self.image, (x, y))

    def addtolist(self,list):
        list.addobject(self)


#NOTE There s no fallthrough for item usage

# Copyright (C) Johan Ceuppens 2011
# Copyright (C) Johan Ceuppens 2010

# Copyright (C) Johan Ceuppens 2009 
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

import pygame
from pygame.locals import *

from inventoryitem import *

class Inventorykey1(Inventoryitem):
    def __init__(self):
        Inventoryitem.__init__(self, "./pics/dungeonkey1-36x36.bmp")

    def use(self,e,game):
        print 'You used Key 1 on %s' % e

# Copyright (C) Johan Ceuppens 2011
# Copyright (C) Johan Ceuppens 2010

# Copyright (C) Johan Ceuppens 2009 
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

import pygame
from pygame.locals import *

from inventoryitem import *

class InventoryLongbow(Inventoryitem):
    def __init__(self):
        Inventoryitem.__init__(self, './pics/longbow1-48x48.bmp')

    def use(self,e,game):
        print 'You used a fairy tunic on %s' % e

# Copyright (C) Johan Ceuppens 2011
# Copyright (C) Johan Ceuppens 2010

# Copyright (C) Johan Ceuppens 2009 
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

import pygame
from pygame.locals import *

from inventoryitem import *

class InventoryLongsword(Inventoryitem):
    def __init__(self):
        Inventoryitem.__init__(self, './pics/longsword1-48x48.bmp')

    def use(self,e,game):
        print 'You used a longsword on %s' % e

# Copyright (C) Johan Ceuppens 2011
# Copyright (C) Johan Ceuppens 2010

# Copyright (C) Johan Ceuppens 2009 
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

import pygame
from pygame.locals import *

from inventoryitem import *

class Inventorymasterkey(Inventoryitem):
    def __init__(self):
        Inventoryitem.__init__(self, "./pics/dungeonmasterkey1-36x36.bmp")

    def use(self,e,game):
        print 'You used a Master Key on %s' % e

# Copyright (C) Johan Ceuppens 2011
# Copyright (C) Johan Ceuppens 2010

# Copyright (C) Johan Ceuppens 2009 
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


import pygame
from pygame.locals import *
from inventorybomb import *
from inventorydefaultsword import *

class Inventory(object):
    def __init__(self,font):
        self.background = pygame.image.load('./pics/blank.bmp').convert()
        self.listrow1 = []
        self.listrow2 = []
	self.ITEMWIDTH = 40
	self.ITEMHEIGHT = 40
	self.ITEMMAX = 7
	#NOTE is in player classes :
	#self.listrow2.append(Inventorydefaultsword())
        #self.listrow1.append(Inventorybomb())
        self.font = font
        self.rectimage = pygame.image.load('./pics/rectinventory-36x36.bmp').convert()
        self.rectimage.set_colorkey((255,255,255))
        self.rectimage.set_colorkey((0,0,255))
        self.selectioncounter = 0 
        self.numberofkeys = 0
        self.keyimage = pygame.image.load('./pics/dungeonkey1.1-36x36.bmp').convert()
        self.keyimage.set_colorkey((0,0,255))
        self.numberofgold = 0
        self.goldcoinimage = pygame.image.load('./pics/goldcoin1.1-36x36.bmp').convert()
        self.goldcoinimage.set_colorkey((0,0,0))
        
    def setrow1(self, r):
        self.listrow1 = r

    def setrow2(self, r):
        self.listrow2 = r

    def addkey(self):
        self.numberofkeys += 1

    def draw(self,screen):

        screen.blit(self.background, (0, 0))
        screen.blit(self.font.render("Inventory", 6, (0,255,0)), (10,10))
        screen.blit(self.font.render("Inventory", 6, (0,0,255)), (12,12))

        screen.blit(self.font.render("Equipment", 6, (0,255,0)), (10,10+self.ITEMHEIGHT))
        screen.blit(self.font.render("Equipment", 6, (0,0,255)), (12,12+self.ITEMHEIGHT))

        screen.blit(self.font.render("Spells", 6, (0,255,0)), (10,10+self.ITEMHEIGHT*2))
        screen.blit(self.font.render("Spells", 6, (0,0,255)), (12,12+self.ITEMHEIGHT*2))

        pos = pygame.mouse.get_pos()
        mousex = pos[0]-18
        mousey = pos[1]-18

        self.selectioncounter = mousex % self.ITEMMAX

##        x = 80 + self.selectioncounter * self.ITEMWIDTH % self.ITEMMAX*self.ITEMWIDTH 
##	y = self.selectioncounter / self.ITEMMAX * self.ITEMWIDTH
	x = mousex ##% self.ITEMMAX*self.ITEMWIDTH 
	y = mousey ##self.selectioncounter / self.ITEMMAX * self.ITEMWIDTH
        self.drawrect(screen,x,y)
        
        for i in range(0,len(self.listrow1)):
            o = self.listrow1[i]
            if o:
                o.draw(screen,80+40*(i%self.ITEMMAX),i/36)

        for i in range(0,len(self.listrow2)):
            o = self.listrow2[i]
            if o:
                o.draw(screen,80+40*(i%self.ITEMMAX),i/36 + self.ITEMHEIGHT)

	
        
        screen.blit(self.keyimage,(10,320))
        screen.blit(self.font.render(" x %d" % self.numberofkeys, 6, (0,0,255)), (36,330))
        screen.blit(self.goldcoinimage,(110,320))
        screen.blit(self.font.render(" x %d" % self.numberofgold, 6, (0,0,255)), (136,330))

    def drawrect(self,screen,x,y):
        screen.blit(self.rectimage, (x, y))


    def moveleft(self):
        if self.selectioncounter > 0:
            self.selectioncounter -= 1

    def moveright(self):
        if self.selectioncounter < self.ITEMMAX * self.ITEMMAX:
            self.selectioncounter += 1

#    def setselection(self):
#        i = 
        
    def getitem(self,o):
        pos = pygame.mouse.get_pos()
        mousex = pos[0]
        mousey = pos[1]
        print 'mousex=%d mousey=%d' % (mousex,mousey)
        if mousex > 80 and mousey < self.ITEMHEIGHT and (mousex - 80) / self.ITEMWIDTH <= len(self.listrow1) and len(self.listrow1) != 0: 
                print '1st mousex=%d mousey=%d' % (mousex,mousey)
                
                o = self.listrow1[(mousex-80) / self.ITEMWIDTH]
                if o:
            	    return o
        if mousex > 80 and mousey > self.ITEMHEIGHT and mousey <= self.ITEMHEIGHT*2 and (mousex-80) / self.ITEMWIDTH < len(self.listrow2) and len(self.listrow2) != 0: 
                print '2nd mousex=%d mousey=%d' % (mousex,mousey)
                o = self.listrow2[(mousex-80) / self.ITEMWIDTH]
                if o:
            	    return o
##	if self.ITEMMAX > self.selectioncounter:
##                if len(self.listrow1) > self.selectioncounter:
##                    o = self.listrow1[self.selectioncounter]
##                    if o:
##            		return o

        return None

    def additem(self,o):
        self.list.append(o)

# Copyright (C) Johan Ceuppens 2011
# Copyright (C) Johan Ceuppens 2010

# Copyright (C) Johan Ceuppens 2009 
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

import pygame
from pygame.locals import *

from inventoryitem import *

class Inventoryscrollinvisibility(Inventoryitem):
    def __init__(self):
        Inventoryitem.__init__(self, "./pics/scroll1.bmp")

    def use(self,e,game):
        print 'You used a scroll of invisibility on %s' % e
        if e:
            return e.usescrollinvisibility(game)
	

# Copyright (C) Johan Ceuppens 2011
# Copyright (C) Johan Ceuppens 2010

# Copyright (C) Johan Ceuppens 2009 
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

import pygame
from pygame.locals import *

from inventoryitem import *

class InventorySpear(Inventoryitem):
    def __init__(self):
        Inventoryitem.__init__(self, './pics/spear1-48x48.bmp')

    def use(self,e,game):
        print 'You used a spear on %s' % e

# Copyright (C) Johan Ceuppens 2011
# Copyright (C) Johan Ceuppens 2010

# Copyright (C) Johan Ceuppens 2009 
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

import pygame
from pygame.locals import *

from inventoryitem import *

class InventoryWand(Inventoryitem):
    def __init__(self):
        Inventoryitem.__init__(self, './pics/wand1-48x48.bmp')

    def use(self,e,game):
        print 'You used a wand on %s' % e

# Copyright (C) Johan Ceuppens 2011
# Copyright (C) Johan Ceuppens 2010

# Copyright (C) Johan Ceuppens 2009 
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

import pygame
from pygame.locals import *

from inventoryitem import *

class InventoryWandRed(Inventoryitem):
    def __init__(self):
        Inventoryitem.__init__(self, './pics/wandred1-48x48.bmp')

    def use(self,e,game):
        print 'You used a red wand on %s' % e

# Copyright (C) Johan Ceuppens 2010
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


import pygame
from pygame.locals import *
from gameobject import *
from stateimagelibrary import *
import random
from time import *

class Knight2(Gameobject):
    ""
    def __init__(self,xx,yy):
	Gameobject.__init__(self, xx, yy)
        self.w = 64
        self.h = 64 
	self.stimlib = Stateimagelibrary()
        image = pygame.image.load('./pics/knight2front1-36x36.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlib.addpicture(image)
        image = pygame.image.load('./pics/knight2front2-36x36.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlib.addpicture(image)
        image = pygame.image.load('./pics/knight2front3-36x36.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlib.addpicture(image)	
        image = pygame.image.load('./pics/knight2front2-36x36.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlib.addpicture(image)

        self.staticimage = pygame.image.load('./pics/knight2front1-36x36.bmp').convert()
        self.staticimage.set_colorkey((0,0,0)) 
	
	self.direction = "down"
        self.talkcounter = 0

    def draw(self, screen, room):
	if (self.direction == "down"):
            self.stimlib.draw(screen, self.x+room.relativex,self.y+room.relativey)
	else:
            screen.blit(self.staticimage,(self.x+room.relativex,self.y+room.relativey))
             
    def update(self,room):
        sleep(.2)
	if (self.direction == "down"):
                if self.y > 180:
                    self.direction = "stop"
	        self.y +=2 
	else:
	        self.y +=0

    def collide(self, room, player):
	if (player.x > self.x+room.relativex  and 
	player.x < self.x+room.relativex+self.w and 
	player.y > self.y+room.relativey and 
	player.y < self.y+room.relativey + self.h):
	    print "collision with Knight2!"
            return 2 
	else:
	    return 0


    def talk(self, screen, font):
       if self.talkcounter == 0:
            return
        
       if self.talkcounter > 2:
                self.talkcounter = 0
                return 
       talkover = 0
       while talkover == 0:
            pygame.display.update()
            if self.talkcounter == 1:
                screen.blit(font.render("Watch out for Gohma", 8, (255,255,255)), (100,100))
            elif self.talkcounter == 2:
                screen.blit(font.render("He spits venom.", 8, (255,255,255)), (100,100))
            for event in pygame.event.get():
                if event.type == QUIT:
                    return
                elif event.type == KEYDOWN:
                    if event.key == K_z:
                        talkover = 1
                        self.talkcounter += 1
                


		 

# Copyright (C) Johan Ceuppens 2010
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


import pygame
from pygame.locals import *
from gameobject import *
from stateimagelibrary import *
import random
from time import *

class Knight(Gameobject):
    ""
    def __init__(self,xx,yy):
	Gameobject.__init__(self, xx, yy)
        self.w = 64
        self.h = 64 
	self.stimlibleft = Stateimagelibrary()	
	self.stimlibright = Stateimagelibrary()	
        image = pygame.image.load('./pics/knightdarkleft1-30x30.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)
        image = pygame.image.load('./pics/knightdarkleft2-30x30.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)
        image = pygame.image.load('./pics/knightdarkleft3-30x30.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)	
        image = pygame.image.load('./pics/knightdarkright1-30x30.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibright.addpicture(image)
        image = pygame.image.load('./pics/knightdarkright2-30x30.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibright.addpicture(image)
        image = pygame.image.load('./pics/knightdarkright3-30x30.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibright.addpicture(image)	
	self.direction = "left"

    def draw(self, screen, room):
	if (self.direction == "left"):
            self.stimlibleft.draw(screen, self.x+room.relativex,self.y+room.relativey)
	elif (self.direction == "right"):
            self.stimlibright.draw(screen, self.x+room.relativex,self.y+room.relativey)
	    
	     
    def update(self,room):
        sleep(.01)
##        self.x-=1
##	if (random.randint(0,100) == 0 and self.direction == "left"):
##	   self.direction = "right"
##	elif (random.randint(0,100) == 0 and self.direction == "right"):
##	   self.direction = "left"
##
	if (not self.collideobjectX(room)): 
	    if (self.direction == "left"):
	        self.x +=2
	        self.direction = "right" 
	    elif (self.direction == "right"):
	        self.x -=2
	        self.direction = "left"


	if (self.direction == "left"):
	        self.x -=1 
	elif (self.direction == "right"):
	        self.x +=1

    def collide(self, room, player):
	if (player.x > self.x+room.relativex  and 
	player.x < self.x+room.relativex+self.w and 
	player.y > self.y+room.relativey and 
	player.y < self.y+room.relativey + self.h):
	    print "collision with Knight!"
	    if player.hit():
		return 1 
	    else:
	    	return 2 
	else:
	    return 0
		 

# Copyright (C) Johan Ceuppens 2010 
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


import pygame
from pygame.locals import *
from gameobject import *

class Knightstatue1(Gameobject):
    ""
    def __init__(self, xx,yy):
        Gameobject.__init__(self,xx,yy)
        self.w = 48 
        self.h = 48 
        self.image = pygame.image.load('./pics/dungeon-knightstatue1-48x48.bmp').convert()
        self.image.set_colorkey((0,0,0)) 

    def collide(self, room, player):
	return 0


# Copyright (C) Johan Ceuppens 2010
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


import pygame
from pygame.locals import *
from gameobject import *
from stateimagelibrary import *
import random

class KoboldWizard(Gameobject):
    ""
    def __init__(self,xx,yy):
	Gameobject.__init__(self, xx, yy)
        self.w = 50
        self.h = 50 
	self.stimlibleft = Stateimagelibrary()	
	self.stimlibright = Stateimagelibrary()	
        image = pygame.image.load('./pics/koboldwizard-50x50.bmp').convert()
        image.set_colorkey((255,255,255)) 
	self.stimlibleft.addpicture(image)
        self.talkcounter = 0

    def draw(self, screen, room):
        self.stimlibleft.draw(screen, self.x+room.relativex,self.y+room.relativey)    
	     
    def update(self,room):
        1

    def collide(self, room, player):
	if (player.x > self.x+room.relativex  and 
	player.x < self.x+room.relativex+self.w and 
	player.y > self.y+room.relativey and 
            player.y < self.y+room.relativey + self.h):
            #print "collision with Kobold Wizard!"
            return 2 ## NOTE 2 for talker
	else:
	    return 0

    def talk(self, screen):
        self.talkcounter += 1
        if self.talkcounter > 2:
                self.talkcounter = 0
        if self.talkcounter == 0:
            return
        if self.talkcounter == 1:
            screen.blit(self.font.render("Watch out for Gohma. He spits venom!", 8, (255,255,255)), (100,100))
        elif self.talkcounter == 2:
            screen.blit(self.font.render("Ask the alchemist for poison.", 8, (255,255,255)), (100,100))
        for event in pygame.event.get():
                if event.type == QUIT:
                    return
                elif event.type == KEYDOWN:
            	    if event.key == K_z:
                        return
       
##        screen.blit(font.render("Watch out for Gohma. He spits venom!",4, (255,255,255)), (10,100))
##        pygame.display.update()
##        sleep(1)
##        for event in pygame.event.get():
##            self.room.draw(screen) 
##           
##            pygame.display.update()
##            if event.type == QUIT:
##                return
##            elif event.type == KEYDOWN:
##                if event.key == K_z:
##                  break

# Copyright (C) Johan Ceuppens 2010
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


import pygame
from pygame.locals import *
from maproom import *
from knight import *
from mongbat import *
from maproom2 import *
from dungeonkey2 import *
from gohma import *
from gohmaup import *

class Maproom10(Maproom):
    "Room with a (big) map"
    def __init__(self,x,y):
        Maproom.__init__(self,x,y)
        self.background = pygame.image.load('./pics/room-bg10.bmp').convert()	#self.gameobjects.append(Dungeonmasterkey(50,50))
	self.gameobjects.append(Dungeonwall(0,0,300,40))
	self.gameobjects.append(Dungeonwall(0,260,300,40))
	self.gameobjects.append(Dungeonwall(0,0,40,300))
	self.gameobjects.append(Gohma(0,20))
	self.gameobjects.append(GohmaUp(0,200))
	if not self.dungeonkey2:
            self.gameobjects.append(Dungeonkey2GohmaLair(130,130))
##	self.gameobjects.append(Dungeonwall(260,0,40,300))
##	self.gameobjects.append(Mongbat(100,50))
##	self.gameobjects.append(Mongbat(200,100))
##	self.gameobjects.append(Mongbat(100,150))
##	self.gameobjects.append(Mongbat(200,200))


    def draw(self,screen):
        screen.blit(self.background, (0+self.relativex, 0+self.relativey))
        for i in self.gameobjects:
	    if i:
                i.draw(screen,self)
 
    def collide(self, player):
	for i in self.gameobjects:
	    if i != None:
		i.update(self)	
	for i in self.gameobjects:
            if i != None:
                id = i.collide(self,player)
                self.relativex = self.prevx
		self.relativey = self.prevy
		return id
	return 0

    def pickup(self, player):###FIX for each room
        for o in self.gameobjects:
            if (o and o.collide(self, player)):##FIX o.colidepickup
                id = o.pickup(self)
                self.dungeonkey2 = 1
		return id
        return 0
    
    def exit(self, game):
        if self.isroomdownexit():
	    self.setxyfromdown()	
	    return 9
	else:
	    return 0

    def removeobject(self, o):
        for i in (0,len(self.gameobjects)-1):
            if (self.gameobjects[i] and self.gameobjects[i] == o):
                print "PICKUP"
                self.gameobjects[i] = None

# Copyright (C) Johan Ceuppens 2010
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


import pygame
from pygame.locals import *
from maproom import *
from tree import *
from tree2 import *
from dungeonentrance1 import *
from maproom2 import *
from goblin1 import *
from box import *

class Maproom1_1_1(Maproom):
    "Room with a (big) map - west of knight's castle"
    def __init__(self,x,y):
        Maproom.__init__(self,x,y)
        self.background = pygame.image.load('./pics/room-bg1_1_1.bmp').convert()
        #FIX	self.gameobjects.append(Dungeonentrance1(0,0))
	self.gameobjects.append(Tree2(10,100))
	self.gameobjects.append(Tree2(100,100))
	self.gameobjects.append(Tree2(200,120))
        self.gameobjects.append(Goblin1(50,230))
        self.gameobjects.append(Goblin1(440,230))
        b = Box(650,0,150,300)
        b.setimage('./pics/knightdungeon1-150x350.bmp',0,0,0)
        self.gameobjects.append(b)
        # upper crevasses
        self.gameobjects.append(Box(0,0,375,75))
        self.gameobjects.append(Box(375,0,100,100))
        self.gameobjects.append(Box(475,0,100,125))
        self.gameobjects.append(Box(500,0,120,180))
        self.gameobjects.append(Box(600,0,50,160))
        self.gameobjects.append(Box(650,0,25,75))
        self.gameobjects.append(Box(675,0,75,40))
        self.gameobjects.append(Box(750,0,50,40))
        # lower crevasses
        self.gameobjects.append(Box(500,220,120,400))
        self.gameobjects.append(Box(0,400,800,100))

 
    def draw(self,screen):
        screen.blit(self.background, (0+self.relativex, 0+self.relativey))
        for i in self.gameobjects:
	    if i != None:
		i.draw(screen,self)

    def collide(self, player):
	for i in self.gameobjects:
	    if i != None: 
		i.update(self)	
	for i in self.gameobjects:
	    if i != None and i.collide(self, player):
		self.relativex = self.prevx
		self.relativey = self.prevy
		return  

    def isroomdownexit(self):
	if self.relativex  < -140 and self.relativex > -200 and self.relativey < -210:### and self.relativey < 20:
		return 1
	return 0

    def setxyfromdown(self):
        self.relativex = 0
	self.relativey = 0

    def isroomleftexit(self):
	if self.relativex  > 100:
		return 1
	return 0

    def setxyfromleft(self):
        self.relativex = 0
	self.relativey = 0
	

    def exit(self, game):
        # To Mithran and Gohma's Lair and Lady of the Lake Knight Chateau
        print 'x=%d y=%d' % (self.relativex,self.relativey)
	if self.relativey < -50 and self.relativex < -580:
	    game.setxy(0,-80)	
	    return 2#FIX
        # To south 
	elif self.isroomdownexit():
            self.setxyfromdown()
            return 1.1#FIX
        # To the west
        elif self.isroomleftexit():
            self.setxyfromleft()
            return 1.1#FIX
	else:
	    return 0 
 
    def collidesword(self,room,player):
        for i in self.gameobjects:
	    if i!= None:
	    	c = i.collide(room,player)
		if c == 1:
			return i ## NOTE : returns collided entity (single)
		self.relativex = self.prevx
		self.relativey = self.prevy
	return None

# Copyright (C) Johan Ceuppens 2010
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


import pygame
from pygame.locals import *
from maproom import *
from knight import *
from blackknight import *
from demon import *
from bombman import *
from turtleflying import *
from ghost1 import *
from ghostwandering import *
from ghostcircling import *
from maproom2 import *
from dungeonmasterkey import *
from dungeonkey1 import *
from mithran import *

class Maproom1_1(Maproom):
    "Room with a (big) map - South of Knight's Castle, Towards Grove"
    def __init__(self,x,y):
        Maproom.__init__(self,x,y)
        self.background = pygame.image.load('./pics/room-bg1_1.bmp').convert()

        #FIX1 archmage Mithran
        self.mithran = Mithran(110,120)
	self.gameobjects.append(self.mithran)
	# walls towards grove
	self.gameobjects.append(Dungeonwall(0,0,100,500))
	self.gameobjects.append(Dungeonwall(200,0,100,500))
	     
    def draw(self,screen):
        screen.blit(self.background, (0+self.relativex, 0+self.relativey))
        for i in self.gameobjects:
	    if i:
                i.draw(screen,self)
 
    def collide(self, player):
	for i in self.gameobjects:
	    if i != None:
		i.update(self)	
	for i in self.gameobjects:
	    if i!= None:
	    	id = i.collide(self,player)
		self.relativex = self.prevx
		self.relativey = self.prevy
		return id
	return 0

    def pickup(self, player):###FIX for each room
        for o in self.gameobjects:
            if (o and o.collide(self, player)):##FIX o.colidepickup
                id = o.pickup(self)
                self.dungeonkey1 = 1
		return id
        return 0
    
    def exit(self, game):
        # FIX
	return 0

    def removeobject(self, o):
        for i in (0,len(self.gameobjects)-1):
            print "o=%s self.gameobjects[i]=%s i=%d" % (o,self.gameobjects[i],i)
            if self.gameobjects[i] == o:
                print "PICKUP or die"
                self.gameobjects[i] = None
		return 

    def collidesword(self,room,player):
        for i in self.gameobjects:
	    if i!= None:
	    	c = i.collide(room,player)
	    	print "i=%s" % i
		if c == 1:
                        print "collision with i=%s!" % i
			return i ## NOTE : returns collided entity (single)
		self.relativex = self.prevx
		self.relativey = self.prevy
	return None

    def isroomdownexit(self):
	if self.relativey < - 320:### and self.relativey < 20:
		return 1
	return 0

    def setxyfromdown(self):
        self.relativex = 0
	self.relativey = 0

    def setxyfromup(self):#FIXME
        self.relativex = -200
	self.relativey = -200
	
	
    def exit(self, game):
        print "x=%d y=%d" % (self.relativex,self.relativey)
        if self.isroomupexit():
	    self.setxyfromup()	    
	    return 1
	elif self.isroomdownexit():
	    self.setxyfromdown()	    
	    return 1.2
	#Trap door: elif self.isroomdownexit():
	#    self.setxyfromdown()	
	#    return 11
	else:
	    return 0


    def talkto(self):#FIXME needs font
            print "talk to in maproom 6"
            ## return self.koboldwiz
            self.mithran.talkcounter = 1 # FIXME public var
            return self.mithran

# Copyright (C) Johan Ceuppens 2010
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


import pygame
from pygame.locals import *
from maproom import *
from knight import *
from mongbat import *
from maproom2 import *
from dungeonmasterkey import *
from gohma import *
from gohmaup import *
from box import *

class Maproom11(Maproom):
    "Room with a (big) map"
    def __init__(self,x,y):
        Maproom.__init__(self,x,y)
        self.background = pygame.image.load('./pics/room-bg11.bmp').convert()
        #self.gameobjects.append(Dungeonmasterkey(50,50))
        self.gameobjects.append(Dungeonwall(260,0,40,300))
	self.gameobjects.append(Dungeonwall(0,0,300,40))
	self.gameobjects.append(Dungeonwall(0,260,300,40))
	self.gameobjects.append(Dungeonwall(0,0,40,300))
	b = Box(85,85,140,25)
	b.setimage('./pics/nopicture.bmp',0,0,255)
	self.gameobjects.append(b)
	b = Box(200,85,25,115)
	b.setimage('./pics/nopicture.bmp',0,0,255)
	self.gameobjects.append(b)
	b = Box(85,200,115,25)
	b.setimage('./pics/nopicture.bmp',0,0,255)
	self.gameobjects.append(b)
	b = Box(85,85,25,115)
	b.setimage('./pics/nopicture.bmp',0,0,255)
	self.gameobjects.append(b)
##	self.gameobjects.append(Gohma(0,20))
##	self.gameobjects.append(GohmaUp(0,200))
##	self.gameobjects.append(Dungeonwall(260,0,40,300))
##	self.gameobjects.append(Mongbat(100,50))
##	self.gameobjects.append(Mongbat(200,100))
##	self.gameobjects.append(Mongbat(100,150))
##	self.gameobjects.append(Mongbat(200,200))


    def draw(self,screen):
        screen.blit(self.background, (0+self.relativex, 0+self.relativey))
        for i in self.gameobjects:
	    if i:
                i.draw(screen,self)
 
    def collide(self, player):
	for i in self.gameobjects:
	    if i != None:
		i.update(self)	
	for i in self.gameobjects:
            if i != None:
                id = i.collide(self,player)
                self.relativex = self.prevx
		self.relativey = self.prevy
		return id
	return 0

##    def pickup(self, player):
##        for o in self.gameobjects:
##            if (o and o.collidepickup(self, player)):
##                o.pickup(self)
##                return
##
    
    def exit(self, game):
        if self.isroomupexit():
	    self.setxyfromup()
	    self.y = -660 # NOTE
	    return 12
	elif self.isroomdownexit():
	    self.setxyfromdown()	
	    return 8
	else:
	    return 0

    def removeobject(self, o):
        for i in (0,len(self.gameobjects)-1):
            if (self.gameobjects[i] and self.gameobjects[i] == o):
                print "PICKUP"
                self.gameobjects[i] = None

# Copyright (C) Johan Ceuppens 2010
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


import pygame
from pygame.locals import *
from maproom import *
from knight import *
from blackknight import *
from demon import *
from bombman import *
from turtleflying import *
from ghost1 import *
from ghostwandering import *
from ghostcircling import *
from maproom2 import *
from dungeonmasterkey import *
from dungeonkey1 import *
from mithran import *

class Maproom1_2(Maproom):
    "Room with a (big) map - Towards second south of Knight's Castle"
    def __init__(self,x,y):
        Maproom.__init__(self,x,y)
        self.background = pygame.image.load('./pics/room-bg1_2.bmp').convert()
	self.gameobjects.append(Dungeonwall(0,0,300,100))
	self.gameobjects.append(Dungeonwall(200,0,100,300))
	self.gameobjects.append(Dungeonwall(0,0,100,300))
	self.gameobjects.append(Dungeonwall(0,200,300,100))
	     
    def draw(self,screen):
        screen.blit(self.background, (0+self.relativex, 0+self.relativey))
        for i in self.gameobjects:
	    if i:
                i.draw(screen,self)
 
    def collide(self, player):
	for i in self.gameobjects:
	    if i != None:
		i.update(self)	
	for i in self.gameobjects:
	    if i!= None:
	    	id = i.collide(self,player)
		self.relativex = self.prevx
		self.relativey = self.prevy
		return id
	return 0

    def pickup(self, player):###FIX for each room
        for o in self.gameobjects:
            if (o and o.collide(self, player)):##FIX o.colidepickup
                id = o.pickup(self)
                self.dungeonkey1 = 1
		return id
        return 0
    
    def exit(self, game):
        # FIX
	return 0

    def removeobject(self, o):
        for i in (0,len(self.gameobjects)-1):
            print "o=%s self.gameobjects[i]=%s i=%d" % (o,self.gameobjects[i],i)
            if self.gameobjects[i] == o:
                print "PICKUP or die"
                self.gameobjects[i] = None
		return 

    def collidesword(self,room,player):
        for i in self.gameobjects:
	    if i!= None:
	    	c = i.collide(room,player)
	    	print "i=%s" % i
		if c == 1:
                        print "collision with i=%s!" % i
			return i ## NOTE : returns collided entity (single)
		self.relativex = self.prevx
		self.relativey = self.prevy
	return None

    def isroomdownexit(self):
	if self.relativey < - 320:### and self.relativey < 20:
		return 1
	return 0

    def setxyfromup(self):#FIXME
        self.relativex = -400
	self.relativey = -200
	
	
    def exit(self, game):
        print "x=%d y=%d" % (self.relativex,self.relativey)
        if self.isroomupexit():
	    self.setxyfromup()	    
	    return 1.1
	else:
	    return 0


    def talkto(self):#FIXME needs font
            print "talk to in maproom 6"
            ## return self.koboldwiz
            self.mithran.talkcounter = 1 # FIXME public var
            return self.mithran

# Copyright (C) Johan Ceuppens 2010
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


import pygame
from pygame.locals import *
from maproom import *
from knight import *
from blackknight import *
from demon import *
from bombman import *
from turtleflying import *
from ghost1 import *
from ghostwandering import *
from ghostcircling import *
from maproom2 import *
from dungeonmasterkey import *
from dungeonkey1 import *
from mithran import *

class Maproom1_2(Maproom):
    "Room with a (big) map - Towards second south of Knight's Castle"
    def __init__(self,x,y):
        Maproom.__init__(self,x,y)
        self.background = pygame.image.load('./pics/room-bg1_2.bmp').convert()
	self.gameobjects.append(Dungeonwall(0,0,100,300))
	self.gameobjects.append(Dungeonwall(0,200,300,100))
	     
    def draw(self,screen):
        screen.blit(self.background, (0+self.relativex, 0+self.relativey))
        for i in self.gameobjects:
	    if i:
                i.draw(screen,self)
 
    def collide(self, player):
	for i in self.gameobjects:
	    if i != None:
		i.update(self)	
	for i in self.gameobjects:
	    if i!= None:
	    	id = i.collide(self,player)
		self.relativex = self.prevx
		self.relativey = self.prevy
		return id
	return 0

    def pickup(self, player):###FIX for each room
        for o in self.gameobjects:
            if (o and o.collide(self, player)):##FIX o.colidepickup
                id = o.pickup(self)
                self.dungeonkey1 = 1
		return id
        return 0
    
    def exit(self, game):
        # FIX
	return 0

    def removeobject(self, o):
        for i in (0,len(self.gameobjects)-1):
            print "o=%s self.gameobjects[i]=%s i=%d" % (o,self.gameobjects[i],i)
            if self.gameobjects[i] == o:
                print "PICKUP or die"
                self.gameobjects[i] = None
		return 

    def collidesword(self,room,player):
        for i in self.gameobjects:
	    if i!= None:
	    	c = i.collide(room,player)
	    	print "i=%s" % i
		if c == 1:
                        print "collision with i=%s!" % i
			return i ## NOTE : returns collided entity (single)
		self.relativex = self.prevx
		self.relativey = self.prevy
	return None

    def isroomdownexit(self):
	if self.relativey < - 100:### and self.relativey < 20:
		return 1
	return 0

    def setxyfromup(self):#FIXME
        self.relativex = -400
	self.relativey = -200
	
	
    def exit(self, game):
        print "x=%d y=%d" % (self.relativex,self.relativey)
        if self.isroomupexit():
	    self.setxyfromup()	    
	    return 1.1
	elif self.isroomdownexit():
	    self.setxyfromdown()	    
	    return 1.3
	else:
	    return 0

# Copyright (C) Johan Ceuppens 2010
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


import pygame
from pygame.locals import *
from maproom import *
from knight import *
from mongbat import *
from maproom2 import *
from dungeonmasterkey import *
from gohma import *
from gohmaup import *
from box import *

class Maproom12(Maproom):
    "Room with a (big) map"
    def __init__(self,x,y):
        Maproom.__init__(self,x,y)
        self.background = pygame.image.load('./pics/room-bg12.bmp').convert()
        self.gameobjects.append(Dungeonwall(0,0,100,900))
	self.gameobjects.append(Dungeonwall(200,0,100,900))


    def draw(self,screen):
        screen.blit(self.background, (0+self.relativex, 0+self.relativey))
        for i in self.gameobjects:
	    if i:
                i.draw(screen,self)
 
    def collide(self, player):
	for i in self.gameobjects:
	    if i != None:
		i.update(self)	
	for i in self.gameobjects:
            if i != None:
                id = i.collide(self,player)
		return id
		self.relativex = self.prevx
		self.relativey = self.prevy
	return 0

##    def pickup(self, player):
##        for o in self.gameobjects:
##            if (o and o.collidepickup(self, player)):
##                o.pickup(self)
##                return
##

    def setxyfromup(self):
        self.relativex = 0
        self.relativey = -700
   
    def exit(self, game):
        if self.isroomupexit():
	    self.setxyfromup()
	    return 13
	#Trap door: elif self.isroomdownexit():
	#    self.setxyfromdown()	
	#    return 11
	else:
	    return 0

    def removeobject(self, o):
        for i in (0,len(self.gameobjects)-1):
            if (self.gameobjects[i] and self.gameobjects[i] == o):
                print "PICKUP"
                self.gameobjects[i] = None

# Copyright (C) Johan Ceuppens 2010
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


import pygame
from pygame.locals import *
from maproom import *
from knight import *
from mongbat import *
from maproom2 import *
from dungeonmasterkey import *
from gohma import *
from gohmaup import *
from box import *
from archgohma import *
from demon import *
from mithranhouse import *
from toadstool import *

class Maproom13(Maproom):
    "Room with a (big) map"
    def __init__(self,x,y):
        Maproom.__init__(self,x,y)
        self.background = pygame.image.load('./pics/room-bg13.bmp').convert()
        ##  upper wall
        b = Box(0,0,1000,300)
	b.setimage('./pics/nopicture.bmp',0,0,255)
	## down wall
	b = Box(0,1000,1000,40)
	b.setimage('./pics/nopicture.bmp',0,0,255)
	##  left wall
	b = Box(0,0,40,1000)
	b.setimage('./pics/nopicture.bmp',0,0,255)
	##  right wall
	b = Box(1000,0,40,1000)
	b.setimage('./pics/nopicture.bmp',0,0,255)

	self.gameobjects.append(b)
	## arch gohmas
	self.gameobjects.append(ArchGohma(300,300))
	self.gameobjects.append(ArchGohma(100,700))
	self.gameobjects.append(ArchGohma(700,400))
	self.gameobjects.append(ArchGohma(700,700))
	## possessed demonic knights
	self.gameobjects.append(Demon(300,400))
	self.gameobjects.append(Demon(400,400))
	self.gameobjects.append(Demon(500,400))
	self.gameobjects.append(Demon(600,400))
	## House of Mithran
	self.gameobjects.append(Mithranhouse(500,500,200,200))
	## Giant Toadstools
	self.gameobjects.append(Toadstool(600,400))
	self.gameobjects.append(Toadstool(700,400))
	self.gameobjects.append(Toadstool(600,500))
	self.gameobjects.append(Toadstool(60,700))
	self.gameobjects.append(Toadstool(248,450))
	self.gameobjects.append(Toadstool(80,800))
	self.gameobjects.append(Toadstool(220,480))
	self.gameobjects.append(Toadstool(300,500))
	self.gameobjects.append(Toadstool(210,550))
	self.gameobjects.append(Toadstool(780,780))
	self.gameobjects.append(Toadstool(648,350))
	self.gameobjects.append(Toadstool(805,630))
	
    def draw(self,screen):
        screen.blit(self.background, (0+self.relativex, 0+self.relativey))
        for i in self.gameobjects:
	    if i:
                i.draw(screen,self)
 
    def collide(self, player):
	for i in self.gameobjects:
	    if i != None:
		i.update(self)	
	for i in self.gameobjects:
            if i != None:
                id = i.collide(self,player)
                self.relativex = self.prevx
		self.relativey = self.prevy
		return id
	return 0

    def isroomdownexit(self):
	if self.relativex  <= 100 and self.relativey < -1080:### and self.relativey < 20:
		return 1
	return 0

    def setxyfromdown(self):
        self.relativex = 0
	self.y = 80

    def isroomhouseexit(self):
	if self.relativex  < -400 and self.relativex > - 600 and self.relativey < -400 and self.relativey > - 600:### and self.relativey < 20:
		return 1
	return 0

    def setxyfromhouse(self):
        self.relativex = 0
	self.relativey = 0
	
	
    def exit(self, game):
        print "x=%d y=%d" % (self.relativex,self.relativey)
        if self.isroomdownexit():
	    self.setxyfromdown()	    
	    return 12
	if self.isroomhouseexit():
	    self.setxyfromhouse()	    
	    return 14
	#FIXME Trap door: elif self.isroomdownexit():
	#    self.setxyfromdown()	
	#    return 11
	else:
	    return 0

    def removeobject(self, o):
        for i in (0,len(self.gameobjects)-1):
            if (self.gameobjects[i] and self.gameobjects[i] == o):
                print "PICKUP"
                self.gameobjects[i] = None

# Copyright (C) Johan Ceuppens 2010
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


import pygame
from pygame.locals import *
from maproom import *
from knight import *
from blackknight import *
from demon import *
from bombman import *
from turtleflying import *
from ghost1 import *
from ghostwandering import *
from ghostcircling import *
from maproom2 import *
from dungeonmasterkey import *
from dungeonkey1 import *
from mithran2 import *

class Maproom14(Maproom):
    "Room with a (big) map"
    def __init__(self,x,y):
        Maproom.__init__(self,x,y)
        self.background = pygame.image.load('./pics/room-bg14.bmp').convert()
        ###	self.gameobjects.append(Bombman(100,50))
###	self.gameobjects.append(Bombman(200,100))
###	self.gameobjects.append(Bombman(100,150))
        self.mithran = Mithran2(110,120)
	self.gameobjects.append(self.mithran)
	self.gameobjects.append(Dungeonwall(0,0,300,100))
	self.gameobjects.append(Dungeonwall(200,0,100,300))
	self.gameobjects.append(Dungeonwall(0,0,100,300))
	self.gameobjects.append(Dungeonwall(0,200,300,100))
	     
    def draw(self,screen):
        screen.blit(self.background, (0+self.relativex, 0+self.relativey))
        for i in self.gameobjects:
	    if i:
                i.draw(screen,self)
 
    def collide(self, player):
	for i in self.gameobjects:
	    if i != None:
		i.update(self)	
	for i in self.gameobjects:
	    if i!= None:
	    	id = i.collide(self,player)
		self.relativex = self.prevx
		self.relativey = self.prevy
		return id
	return 0

    def pickup(self, player):###FIX for each room
        for o in self.gameobjects:
            if (o and o.collide(self, player)):##FIX o.colidepickup
                id = o.pickup(self)
                self.dungeonkey1 = 1
		return id
        return 0
    
    def exit(self, game):
        # FIX
	return 0

    def removeobject(self, o):
        for i in (0,len(self.gameobjects)-1):
            print "o=%s self.gameobjects[i]=%s i=%d" % (o,self.gameobjects[i],i)
            if self.gameobjects[i] == o:
                print "PICKUP or die"
                self.gameobjects[i] = None
		return 

    def collidesword(self,room,player):
        for i in self.gameobjects:
	    if i!= None:
	    	c = i.collide(room,player)
	    	print "i=%s" % i
		if c == 1:
                        print "collision with i=%s!" % i
			return i ## NOTE : returns collided entity (single)
		self.relativex = self.prevx
		self.relativey = self.prevy
	return None

    def isroomhouseexit(self):
	if self.relativex  < 60 and self.relativex > -10 and self.relativey < -70 and self.relativey > - 130:### and self.relativey < 20:
		return 1
	return 0

    def setxyfromhouse(self):
        self.relativex = -600
	self.relativey = -500
	
	
    def exit(self, game):
        print "x=%d y=%d" % (self.relativex,self.relativey)
        if self.isroomhouseexit():
	    self.setxyfromhouse()	    
	    return 13
	#Trap door: elif self.isroomdownexit():
	#    self.setxyfromdown()	
	#    return 11
	else:
	    return 0


    def talkto(self):#FIXME needs font
            print "talk to in maproom 6"
            ## return self.koboldwiz
            self.mithran.talkcounter = 1 # FIXME public var
            return self.mithran

# Copyright (C) Johan Ceuppens 2010
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


import pygame
from pygame.locals import *
from maproom import *
from tree import *
from tree2 import *
from dungeonentrance1 import *
from dungeonkey1 import *
from maproomdungeon import *
from maproomdungeonnorthwall import *
from goblin1 import *
from goblin2 import *
from goblin3 import *
from butterfly2 import *
from centaur1 import *
from tilebox import *
from snake1 import *
from snake2 import *
from rubysword import *
from beholder import *
from beholderbat import *

class Maproom1(MaproomDungeon):
    "Room with a (big) map"
    def __init__(self,x,y,aiengine):
        MaproomDungeon.__init__(self,x,y)
        self.background = pygame.image.load('./pics/room-bg1.bmp').convert()
        ###self.northwall1 = Tilebox(1,1,60,48,16,1,'./pics/walldungeonnorth2-beholderglass-60x48.bmp')
        self.northwall1 = Tilebox(1,1,60,48,13,1,'./pics/walldungeonnorth1-60x48.bmp')
        self.southwall1 = Tilebox(1,200,30,48,13,1,'./pics/walldungeonsouth1-30x48.bmp')
        self.westwall1 = Tilebox(360,200,48,60,1,10,'./pics/walldungeonwest1-48x60.bmp')
        self.eastwall1 = Tilebox(775,1,48,60,1,14,'./pics/walldungeoneast1-48x60.bmp')
        #self.tileboxes.append(self.northwall1)
        #self.tileboxes.append(self.westwall1)
        #self.tileboxes.append(self.eastwall1)
        #self.tileboxes.append(self.southwall1)


        #FIX	self.gameobjects.append(Dungeonentrance1(0,0))
##	self.gameobjects.append(Tree2(10,100))
##	self.gameobjects.append(Tree2(100,100))
##	self.gameobjects.append(Tree2(200,120))
        self.centaur1 = Centaur1(50,230,aiengine)
        self.gameobjects.append(self.centaur1)
        self.centaur2 = Centaur1(440,230,aiengine)
        self.gameobjects.append(self.centaur2)

        self.aiengine = aiengine
        self.aiengine.add(self.centaur1)
        self.aiengine.add(self.centaur2)

        self.gameobjects.append(Butterfly2(100,100))
        self.gameobjects.append(Butterfly2(300,180))
        self.gameobjects.append(Butterfly2(500,120))
        
        self.gameobjects.append(Dungeonkey1(100,120))
##        b = Box(650,0,150,300)
##        b.setimage('./pics/knightdungeon1-150x350.bmp',0,0,0)
##        self.gameobjects.append(b)
##        # upper crevasses
##        self.gameobjects.append(Box(0,0,375,75))
##        self.gameobjects.append(Box(375,0,100,100))
##        self.gameobjects.append(Box(475,0,100,125))
##        self.gameobjects.append(Box(500,0,120,180))
##        self.gameobjects.append(Box(600,0,50,160))
##        self.gameobjects.append(Box(650,0,25,75))
##        self.gameobjects.append(Box(675,0,75,40))
##        self.gameobjects.append(Box(750,0,50,40))
##        # lower crevasses
##        self.gameobjects.append(Box(500,220,120,400))
##        self.gameobjects.append(Box(0,400,800,100))
        #self.addnorthwall(0,0)
 
    def draw(self,screen,player):
        # draw bg
        screen.blit(self.background, (0+self.relativex, 0+self.relativey))
        # draw walls
        # draw automove
        MaproomDungeon.draw(self,screen)
        for t in self.tileboxes:
            t.draw(screen,self.relativex,self.relativey)
        #self.southwall1.draw(screen,self.relativex,self.relativey)
        # draw gameobjects
        for i in self.gameobjects:
	    if i != None:
		i.update(self,player)
		i.draw(screen,self)
	
    def pickup(self, player):###FIX for each room
	###print 'pickup1'
        for o in self.gameobjects:
            if (o and o.collide(self, player)):##FIX o.colidepickup
                id = o.pickup(self)
                self.dungeonkey1 = 1
		print 'pickup'
		return id
        return 0
    

    def isroomdownexit(self):
	if self.relativex  < -250 and self.relativex > -650 and self.relativey < -650:
		return 1
	return 0

    def setxyfromdown(self):
        self.relativex = 0
	self.relativey = 0

    def exit(self, game):
	if self.isroomdownexit():
		self.setxyfromdown()
		return 2
	return 0 

    def talkto(self):#FIXME needs font
            print "talk to in maproom 6"
            ## return self.koboldwiz
            self.centaur1.talkcounter = 1
            return (self.centaur1,self.centaur2)
 
    def collidesword(self,player):
        for i in self.gameobjects:
	    if i!= None:
	    	id = i.collidewithsword(self,player)
		#self.relativex = self.prevx
		#self.relativey = self.prevy
		return i ## NOTE : returns collided entity (single)
	return None


    def removeobject(self, o):
        for i in range(0,len(self.gameobjects)):
            if self.gameobjects[i] == o:
                self.gameobjects[i] = None

# Copyright (C) Johan Ceuppens 2010
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


import pygame
from pygame.locals import *
from maproom import *
from tree import *
from tree2 import *
from dungeonentrance1 import *
from maproomdungeon import *
from maproomdungeonnorthwall import *
from goblin1 import *
from goblin2 import *
from goblin3 import *
from tilebox import *
from snake1 import *
from rubysword import *
from beholder import *
from beholderbat import *
from snake2 import *

class Maproom2(MaproomDungeon):
    "Room with a (big) map"
    def __init__(self,x,y):
        MaproomDungeon.__init__(self,x,y)
        self.background = pygame.image.load('./pics/room-bg2.bmp').convert()
        #self.westwall1 = Tilebox(1,1,48,60,1,14,'./pics/walldungeonwest2-48x60.bmp')
        #self.eastwall1 = Tilebox(775,1,48,60,1,14,'./pics/walldungeoneast1-48x60.bmp')
        #self.tileboxes.append(self.westwall1)
        #self.tileboxes.append(self.eastwall1)
        self.wall1 = Tilebox(600,500,100,100,2,1,'./pics/walldungeon1-100x100.bmp')
        self.tileboxes.append(self.wall1)
        self.cave1 = Tilebox(500,500,100,100,1,1,'./pics/walldungeoncave2-100x100.bmp')
        self.tileboxes.append(self.cave1)

        self.gameobjects.append(Goblin3(100,100))
        self.gameobjects.append(Goblin3(150,100))
        self.gameobjects.append(Goblin3(240,140))
        self.gameobjects.append(Goblin3(350,180))
        self.gameobjects.append(Goblin3(380,180))
        self.gameobjects.append(Goblin3(400,100))
        self.gameobjects.append(Goblin3(450,100))
        self.gameobjects.append(Goblin3(540,120))
        #self.gameobjects.append(Snake1(680,140))
        #self.gameobjects.append(Beholder(300,100))
        #self.gameobjects.append(BeholderBat(300,100))
	#self.gameobjects.append(RubySword(400,100))

        #FIX	self.gameobjects.append(Dungeonentrance1(0,0))
##	self.gameobjects.append(Tree2(10,100))
##	self.gameobjects.append(Tree2(100,100))
##	self.gameobjects.append(Tree2(200,120))
##        self.gameobjects.append(Goblin1(50,230))
##        self.gameobjects.append(Goblin1(440,230))
##        b = Box(650,0,150,300)
##        b.setimage('./pics/knightdungeon1-150x350.bmp',0,0,0)
##        self.gameobjects.append(b)
##        # upper crevasses
##        self.gameobjects.append(Box(0,0,375,75))
##        self.gameobjects.append(Box(375,0,100,100))
##        self.gameobjects.append(Box(475,0,100,125))
##        self.gameobjects.append(Box(500,0,120,180))
##        self.gameobjects.append(Box(600,0,50,160))
##        self.gameobjects.append(Box(650,0,25,75))
##        self.gameobjects.append(Box(675,0,75,40))
##        self.gameobjects.append(Box(750,0,50,40))
##        # lower crevasses
##        self.gameobjects.append(Box(500,220,120,400))
##        self.gameobjects.append(Box(0,400,800,100))
        #self.addnorthwall(0,0)
 
    def draw(self,screen,player):
        # draw bg
        screen.blit(self.background, (0+self.relativex, 0+self.relativey))
        # draw walls
        MaproomDungeon.draw(self,screen)
        for t in self.tileboxes:
            t.draw(screen,self.relativex,self.relativey)
        #self.southwall1.draw(screen,self.relativex,self.relativey)
        # draw gameobjects
        for i in self.gameobjects:
	    if i != None:
		i.update(self,player)
		i.draw(screen,self)
	
    def isroomupexit(self):
	if self.relativey  > 150:
		return 1
	return 0

    def setxyfromup(self):
        self.relativex = -640 
	self.relativey = -640

    def exit(self, game):
	if self.isroomupexit():
		self.setxyfromup()
		return 1 
	return 0 
 
    def collidesword(self,player):
        for i in self.gameobjects:
	    if i!= None:
	    	id = i.collidewithsword(self,player)
		#self.relativex = self.prevx
		#self.relativey = self.prevy
		return i ## NOTE : returns collided entity (single)
	return None


    def removeobject(self, o):
        for i in range(0,len(self.gameobjects)):
            if self.gameobjects[i] == o:
                self.gameobjects[i] = None

# Copyright (C) Johan Ceuppens 2010
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


import pygame
from pygame.locals import *
from maproom import *
from blackknight import *
from bombman import *
from mongbat import *
from maproom2 import *
from dungeonmasterkey import *

class Maproom3(Maproom):
    "Room with a (big) map"
    def __init__(self,x,y):
        Maproom.__init__(self,x,y)
        self.background = pygame.image.load('./pics/room-bg3.bmp').convert()
        self.gameobjects.append(Dungeonwall(0,0,300,40))
	self.gameobjects.append(Dungeonwall(0,260,300,40))
	self.gameobjects.append(Dungeonwall(0,0,40,300))
	self.gameobjects.append(Dungeonwall(260,0,40,300))
        self.gameobjects.append(BlackKnight(100,50))
	self.gameobjects.append(BlackKnight(200,100))
	self.gameobjects.append(BlackKnight(100,150))
	self.gameobjects.append(BlackKnight(200,200))


    def draw(self,screen):
        screen.blit(self.background, (0+self.relativex, 0+self.relativey))
        for i in self.gameobjects:
	    if i:
                i.draw(screen,self)
 
    def collide(self, player):
	for i in self.gameobjects:
	    if i != None:
		i.update(self)	
	for i in self.gameobjects:
	    if i!= None:
	    	id = i.collide(self,player)
	    	self.relativex = self.prevx
		self.relativey = self.prevy
		return id
	return 0#FIX

##    def pickup(self, player):
##        for o in self.gameobjects:
##            if (o and o.collidepickup(self, player)):
##                o.pickup(self)
##                return

    
    def exit(self, game):
        if self.isroomrightexit():
	    self.setxyfromright()	
	    return 2
	elif self.isroomleftexit():
	    self.setxyfromleft()	
	    return 4 
	else:
	    return 0

    def removeobject(self, o):
        for i in (0,len(self.gameobjects)-1):
            if (self.gameobjects[i] and self.gameobjects[i] == o):
                print "PICKUP"
                self.gameobjects[i] = None

    def collidesword(self,room,player):
        for i in self.gameobjects:
	    if i!= None:
	    	c = i.collide(room,player)
		if c == 1:
			return i ## NOTE : returns collided entity (single)
		self.relativex = self.prevx
		self.relativey = self.prevy
	return None

# Copyright (C) Johan Ceuppens 2010
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


import pygame
from pygame.locals import *
from maproom import *
from knight import *
from blackknight import *
from maproom2 import *
from dungeonmasterkey import *

class Maproom4(Maproom):
    "Room with a (big) map"
    def __init__(self,x,y):
        Maproom.__init__(self,x,y)
        self.background = pygame.image.load('./pics/room-bg4.bmp').convert()
        self.gameobjects.append(Dungeonwall(0,0,300,40))
	self.gameobjects.append(Dungeonwall(0,260,300,40))
	self.gameobjects.append(Dungeonwall(0,0,40,300))
	self.gameobjects.append(Dungeonwall(260,0,40,300))
##FIX	self.gameobjects.append(Dungeonstatue1(200,100))
##	self.gameobjects.append(Dungeonstatue1(60,100))
	self.gameobjects.append(BlackKnight(100,50))
	self.gameobjects.append(BlackKnight(200,100))
	self.gameobjects.append(BlackKnight(100,150))
	self.gameobjects.append(BlackKnight(200,200))
 
    def draw(self,screen):
        screen.blit(self.background, (0+self.relativex, 0+self.relativey))
        for i in self.gameobjects:
	    if i:
                i.draw(screen,self)
 
    def collide(self, player):
	for i in self.gameobjects:
	    if i != None:
		i.update(self)	
	for i in self.gameobjects:
	    if i!= None:
	    	id = i.collide(self,player)
		self.relativex = self.prevx
		self.relativey = self.prevy
		return id
	return 0

##    def pickup(self, player):
##        for o in self.gameobjects:
##            if (o and o.collidepickup(self, player)):
##                o.pickup(self)
##                return
##    

    def exit(self, game):
        if self.isroomleftexit():
	    self.setxyfromleft()	
	    return 5
        elif self.isroomrightexit():
	    self.setxyfromright()	
	    return 3 
	else:
	    return 0

    def removeobject(self, o):
        for i in (0,len(self.gameobjects)-1):
            if (self.gameobjects[i] and self.gameobjects[i] == o):
                print "PICKUP"
                self.gameobjects[i] = None

    def removeobject(self, o):
        for i in (0,len(self.gameobjects)-1):
            if (self.gameobjects[i] and self.gameobjects[i] == o):
                print "PICKUP"
                self.gameobjects[i] = None

    def collidesword(self,room,player):
        for i in self.gameobjects:
	    if i!= None:
	    	c = i.collide(room,player)
		if c == 1:
			return i ## NOTE : returns collided entity (single)
		self.relativex = self.prevx
		self.relativey = self.prevy
	return None

# Copyright (C) Johan Ceuppens 2010
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


import pygame
from pygame.locals import *
from maproom import *
from knight import *
from blackknight import *
from demon import *
from bombman import *
from turtleflying import *
from ghost1 import *
from ghostwandering import *
from ghostcircling import *
from maproom2 import *
from dungeonmasterkey import *
from dungeonkey1 import *

class Maproom5(Maproom):
    "Room with a (big) map"
    def __init__(self,x,y):
        Maproom.__init__(self,x,y)
        self.background = pygame.image.load('./pics/room-bg5.bmp').convert()
        ###	self.gameobjects.append(Bombman(100,50))
###	self.gameobjects.append(Bombman(200,100))
###	self.gameobjects.append(Bombman(100,150))
	self.gameobjects.append(GhostWandering(200,200))
	self.gameobjects.append(GhostWandering(200,240))
	self.gameobjects.append(Ghostcircling(20,20))
	self.gameobjects.append(Dungeonwall(0,0,300,10))
	self.gameobjects.append(Dungeonwall(0,290,300,10))
	self.gameobjects.append(Dungeonwall(0,0,10,300))
	self.gameobjects.append(Dungeonwall(290,0,10,300))
	# NOTE eventually keep last for easy removal
	if not self.dungeonkey1:
            self.gameobjects.append(Dungeonkey1(40,250))
            
    def draw(self,screen):
        screen.blit(self.background, (0+self.relativex, 0+self.relativey))
        for i in self.gameobjects:
	    if i:
                i.draw(screen,self)
 
    def collide(self, player):
	for i in self.gameobjects:
	    if i != None:
		i.update(self)	
	for i in self.gameobjects:
	    if i!= None:
	    	id = i.collide(self,player)
		self.relativex = self.prevx
		self.relativey = self.prevy
		return id
	return 0

    def setxyfromroomtotower(self):
        self.x = 0 
        self.y = -100

    def isroomtowerexit(self):
	if self.relativex > -10 and self.relativex < 15 and self.relativey > 40:
		return 1
	return 0


    def pickup(self, player):###FIX for each room
        for o in self.gameobjects:
            if (o and o.collide(self, player)):##FIX o.colidepickup
                id = o.pickup(self)
                self.dungeonkey1 = 1
		return id
        return 0
    
    def exit(self, game):
        if self.isroomrightexit():
	    self.setxyfromright()	
	    return 4
	elif self.isroomtowerexit():
	    self.setxyfromroomtotower()	
	    return 6
	else:
	    return 0

    def removeobject(self, o):
        for i in (0,len(self.gameobjects)-1):
            print "o=%s self.gameobjects[i]=%s i=%d" % (o,self.gameobjects[i],i)
            if self.gameobjects[i] == o:
                print "PICKUP or die"
                self.gameobjects[i] = None
		return 

    def collidesword(self,room,player):
        for i in self.gameobjects:
	    if i!= None:
	    	c = i.collide(room,player)
	    	print "i=%s" % i
		if c == 1:
                        print "collision with i=%s!" % i
			return i ## NOTE : returns collided entity (single)
		self.relativex = self.prevx
		self.relativey = self.prevy
	return None



# Copyright (C) Johan Ceuppens 2010
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


import pygame
from pygame.locals import *
from maproom import *
from maproom1 import *
from tree import *
from knightstatue1 import *
from dungeonwall import *
from koboldwizard import *
from dungeonstatue2 import *
from dungeonstatue3 import *
from dungeonentrance2 import *
from knight2 import *
from time import *

class Maproom6(Maproom):
    "Room with a (big) map"
    def __init__(self,x,y):
        Maproom.__init__(self,x,y)
        self.background = pygame.image.load('./pics/room-bg6.bmp').convert()
        self.gameobjects.append(Dungeonwall(0,0,300,40))
	self.gameobjects.append(Dungeonwall(0,260,40,300))
	self.gameobjects.append(Dungeonwall(0,0,40,300))
	self.gameobjects.append(Dungeonwall(0,260,300,40))
        self.gameobjects.append(Dungeonstatue2(100,76))
        self.gameobjects.append(Dungeonstatue3(160,76))
        self.gameobjects.append(Dungeonentrance2(130,0))
	#self.koboldwiz = KoboldWizard(100,60)
        #self.gameobjects.append(self.koboldwiz)
	self.knight = Knight2(50,50)
	self.gameobjects.append(self.knight)
        self.flag = 0
 
    def draw(self,screen):
        ###FIX numpy ### a = pygame.surfarray.pixels3d(pygame.display.get_surface())
        ###a = pygame.surfarray.array3d(pygame.display.get_surface())
	###a = pygame.display.get_surface().copy()
        #FIXif self.flag == 1:
        screen.blit(self.background, (0+self.relativex, 0+self.relativey))
        for i in self.gameobjects:
            if i != None:
                i.draw(screen,self)
        return
        
##	
##        for i in range(0,300):
##            for j in range(0,300):
##                ###c = a[j][i]
##                R = 255 >> 1
##                G = 0
##                B = 0
##                color = (R,G,B) ###(c[0],c[1],c[2])
##                
##                pygame.draw.line(pygame.display.get_surface(),color,(j,i),(j,i))
##        pygame.display.update()
##        sleep(.1)
##        for i in range(0,300):
##             for j in range(0,300):
##                ###c = a[j][i]
##                R = 255 >> 2
##                G = 0
##                B = 0
##                color = (R,G,B) ###(c[0],c[1],c[2])
##                
##                pygame.draw.line(pygame.display.get_surface(),color,(j,i),(j,i))
##        pygame.display.update()
##        sleep(.1)
##        for i in range(0,300):
##            for j in range(0,300):
##                ###c = a[j][i]
##                R = 255 >> 2
##                G = 0
##                B = 0
##                color = (R,G,B) ###(c[0],c[1],c[2])
##                
##                pygame.draw.line(pygame.display.get_surface(),color,(j,i),(j,i))
##        pygame.display.update()
##        sleep(.1)
##        for i in range(0,300):
##            for j in range(0,300):
##                ###c = a[j][i]
##                R = 0
##                G = 0
##                B = 0
##                color = (R,G,B) ###(c[0],c[1],c[2])
##                
##                pygame.draw.line(pygame.display.get_surface(),color,(j,i),(j,i))
##	self.flag = 1
	
    def collide(self, player):
	for i in self.gameobjects:
	    if i != None:
		i.update(self)	
	for i in self.gameobjects:
            if i != None:
                c = i.collide(self,player)
                ###FIX in all maproom collisions
		if c != 0:###FIXME put this in other room collides also
                    #print "->i=%s c=%s" % (i,c)
                    return c
		self.relativex = self.prevx
		self.relativey = self.prevy
	return 0

    def exit(self, game):
        if self.isroomupexit():
	    self.setxyfromup()	
	    return 7
	elif self.isroomdownexit():
	    self.setxyfromdown()	
	    return 5
##        if self.relativey > 100 and self.relativex > -10 and self.relativex < 20:
##	    game.setxy(0,80)
##	    return 4
##	elif self.relativey < -100 and self.relativex > -10 and self.relativex < 20:
##	    game.setxy(0,-25)
##	    return 1
##	if self.relativex < -100 and self.relativey > -10 and self.relativey < 20:
##	    game.setxy(0,0)
##	    return 7
	else:
	    return 0

	def talkto(self):#FIXME needs font
            print "talk to in maproom 6"
            ## return self.koboldwiz
            self.knight.talkcounter = 1
            return self.knight

##        def pickup(self, player):
##            for o in self.gameobjects:
##                if (o and o.collidepickup(self, player)):
##                    id = o.pickup(self)
##                    return id
##            return 0

    def removeobject(self, o):
        for i in self.gameobjects:
            if o:
                if o == i:
                    i = None##FIXME1

    def removeentrance2(self):
        self.gameobjects[6] = None
               
    def collidesword(self,room,player):
        for i in self.gameobjects:
	    if i!= None:
	    	c = i.collide(room,player)
		if c == 1:
			return i ## NOTE : returns collided entity (single)
		self.relativex = self.prevx
		self.relativey = self.prevy
	return None

# Copyright (C) Johan Ceuppens 2010
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


import pygame
from pygame.locals import *
from maproom import *
from knight import *
from blackknight import *
from maproom2 import *
from brokenwall import *

class Maproom7(Maproom):
    "Room with a (big) map"
    def __init__(self,x,y):
        Maproom.__init__(self,x,y)
        self.background = pygame.image.load('./pics/room-bg7.bmp').convert()
        self.gameobjects.append(Dungeonwall(0,0,300,40))
	self.gameobjects.append(Dungeonwall(0,260,300,40))
	self.gameobjects.append(Dungeonwall(0,0,40,300))
	self.gameobjects.append(Dungeonwall(260,0,40,300))
	###FIX self.gameobjects.append(Dungeonbrokenwall(100,-9))
	###self.gameobjects.append(Dungeonstatue1(150,150))
	self.gameobjects.append(Knight(100,50))
	self.gameobjects.append(Knight(200,100))
	self.gameobjects.append(Knight(100,150))
	self.gameobjects.append(Knight(200,200))
 
    def draw(self,screen):
        screen.blit(self.background, (0+self.relativex, 0+self.relativey))
        for i in self.gameobjects:
	    if i:
                i.draw(screen,self)
 
    def collide(self, player):
	for i in self.gameobjects:
	    if i != None:
		i.update(self)	
	for i in self.gameobjects:
            if i!= None:
                id = i.collide(self,player)
		self.relativex = self.prevx
		self.relativey = self.prevy
		return id
	return 0
    
    def exit(self, game):
        if self.isroomleftexit():
	    self.setxyfromleft()	
	    return 8
	else:
	    return 0 

    
##    def pickup(self, player):
##        for o in self.gameobjects:
##            if (o and o.collidepickup(self, player)):
##                id = o.pickup(self)
##                return id
##        return 0
##    

    def removeobject(self, o):
        for i in (0,len(self.gameobjects)-1):
            if (self.gameobjects[i] and self.gameobjects[i] == o):
                print "PICKUP"
                self.gameobjects[i] = None


    def collidesword(self,room,player):
        for i in self.gameobjects:
	    if i!= None:
	    	c = i.collide(room,player)
		if c == 1:
			return i ## NOTE : returns collided entity (single)
		self.relativex = self.prevx
		self.relativey = self.prevy
	return None

# Copyright (C) Johan Ceuppens 2010
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


import pygame
from pygame.locals import *
from maproom import *
from knight import *
from mongbat import *
from maproom2 import *
from dungeonmasterkey import *
from gohma import *
from gohmaup import *

class Maproom8(Maproom):
    "Room with a (big) map"
    def __init__(self,x,y):
        Maproom.__init__(self,x,y)
        self.background = pygame.image.load('./pics/room-bg8.bmp').convert()
        #self.gameobjects.append(Dungeonmasterkey(50,50))
	self.gameobjects.append(Dungeonwall(0,0,300,40))
	self.gameobjects.append(Dungeonwall(0,260,300,40))
	self.gameobjects.append(Dungeonwall(0,0,40,300))
	self.gameobjects.append(Gohma(0,20))
	self.gameobjects.append(GohmaUp(0,200))
##	self.gameobjects.append(Dungeonwall(260,0,40,300))
##	self.gameobjects.append(Mongbat(100,50))
##	self.gameobjects.append(Mongbat(200,100))
##	self.gameobjects.append(Mongbat(100,150))
##	self.gameobjects.append(Mongbat(200,200))


    def draw(self,screen):
        screen.blit(self.background, (0+self.relativex, 0+self.relativey))
        for i in self.gameobjects:
	    if i:
                i.draw(screen,self)
 
    def collide(self, player):
	for i in self.gameobjects:
	    if i != None:
		i.update(self)	
	for i in self.gameobjects:
            if i != None:
                id = i.collide(self,player)
                self.relativex = self.prevx
		self.relativey = self.prevy
		return id
	return 0

##    def pickup(self, player):
##        for o in self.gameobjects:
##            if (o and o.collidepickup(self, player)):
##                o.pickup(self)
##                return
##

    
    def exit(self, game):
        if self.isroomupexit():
	    self.setxyfromup()	
	    return 11
	elif self.isroomrightexit():
            self.setxyfromright()
	    return 7
        elif self.isroomleftexit():
	    self.setxyfromleft()	
	    return 9
	elif self.isroomdownexit():
	    self.setxyfromdown()	
	    return 15###FIX
	else:
	    return 0
##        if self.isroomleftexit():
##	    self.setxyfromleft()	
##	    return 9
##	elif self.isroomrightexit():
##	    self.setxyfromright()	
##	    return 10
##	else:
	    return 0

    def removeobject(self, o):
        for i in (0,len(self.gameobjects)-1):
            if (self.gameobjects[i] and self.gameobjects[i] == o):
                print "PICKUP"
                self.gameobjects[i] = None

# Copyright (C) Johan Ceuppens 2010
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


import pygame
from pygame.locals import *
from maproom import *
from knight import *
from mongbat import *
from maproom2 import *
from dungeonmasterkey import *
from gohma import *
from gohmaup import *
from gohmaright import *
from demon import *

class Maproom9(Maproom):
    "Room with a (big) map"
    def __init__(self,x,y):
        Maproom.__init__(self,x,y)
        self.background = pygame.image.load('./pics/room-bg9.bmp').convert()	#self.gameobjects.append(Dungeonmasterkey(50,50))
	self.gameobjects.append(Dungeonwall(0,0,300,40))
	self.gameobjects.append(Dungeonwall(0,260,300,40))
	self.gameobjects.append(Dungeonwall(0,0,40,300))
        self.gameobjects.append(Dungeonwall(260,0,40,300))
	### self.gameobjects.append(GohmaRight(50,50))
	self.gameobjects.append(Demon(50,50))

    def draw(self,screen):
        screen.blit(self.background, (0+self.relativex, 0+self.relativey))
        for i in self.gameobjects:
	    if i:
                i.draw(screen,self)
 
    def collide(self, player):
	for i in self.gameobjects:
	    if i != None:
		i.update(self)	
	for i in self.gameobjects:
            if i != None:
                id = i.collide(self,player)
                self.relativex = self.prevx
		self.relativey = self.prevy
		return id
	return 0

##    def pickup(self, player):
##        for o in self.gameobjects:
##            if (o and o.collidepickup(self, player)):
##                o.pickup(self)
##                return
##

    def exit(self, game):
        if self.isroomrightexit():
	    self.setxyfromright()	
	    return 8
	elif self.isroomdownexit():
	    self.setxyfromdown()	
	    return 10
	else:
	    return 0

    def removeobject(self, o):
        for i in (0,len(self.gameobjects)-1):
            if (self.gameobjects[i] and self.gameobjects[i] == o):
                print "PICKUP"
                self.gameobjects[i] = None

# Copyright (C) Johan Ceuppens 2010
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


import pygame
from pygame.locals import *
from koboldwizard import *
from time import *

class MaproomBase:
    "Room with a (big) map"
    def __init__(self,x,y):
        ###Room.__init__(self)
        self.prevx = x
        self.prevy = y
        self.relativex = x
        self.relativey = y 
        self.background = pygame.image.load('./pics/blank.bmp').convert()
        self.direction = "north"
        
    def draw(self,screen):
	##print "x=%d" % self.relativex 
        screen.blit(self.background, (0+self.relativex, 0+self.relativey))

        
    def update(self,room,player):
        1

    def undomove(self):
        if self.direction == "north":
            self.movedown()
            self.movedown()
        elif self.direction == "south":
            self.moveup()
            self.moveup()
        elif self.direction == "west":
            self.moveright()
            self.moveright()
        elif self.direction == "east":
            self.moveleft()
            self.moveleft()
 
    def moveup(self):
        self.direction = "north"
	self.prevx = self.relativex
	self.prevy = self.relativey + 1
        self.relativey = self.relativey - 10

    def movedown(self):
        self.direction = "south"
	self.prevx = self.relativex
	self.prevy = self.relativey - 1
        self.relativey = self.relativey + 10

    def moveleft(self):
        self.direction = "west"
	self.prevx = self.relativex + 1
	self.prevy = self.relativey
        self.relativex = self.relativex - 10

    def moveright(self):
        self.direction = "east"
	self.prevx = self.relativex - 1
	self.prevy = self.relativey
        self.relativex = self.relativex + 10

    def setxyup(self):
        self.x = -80 
        self.y = -80

    def setxydown(self):
        self.x = -80 
        self.y = -80

    def talkto(self):
        return None

    def pickup(self, player):
        for i in range(0,len(self.gameobjects)):
	    o = self.gameobjects[i]
            if o and o.collide(self, player):
                id = o.pickup(self)
		self.gameobjects[i] = None
                return id# FIX 3 
        return 0


    def collidesword(self,player):
        for i in self.gameobjects:
	    if i!= None:
	    	c = i.collide(self,player)
		if c == 1:
			return i ## NOTE : returns collided entity (single)
		self.relativex = self.prevx
		self.relativey = self.prevy
        return None

          

# Copyright (C) Johan Ceuppens 2010
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


import pygame
from pygame.locals import *
from koboldwizard import *
from time import *
from maproom import *

# each wall has its own pic, for dithered and changed images
class MaproomEastDungeonWall:
    "Room with a (big) map"
    def __init__(self,x,y):
        self.x = x
        self.y = y
        self.wallimage = pygame.load.image('./pics/walldungeon1-60x48.bmp')
        
        
    def draw(self,screen):
	##print "x=%d" % self.relativex 
        screen.blit(self.wall, (0+self.relativex, 0+self.relativey))

# Copyright (C) Johan Ceuppens 2010
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


import pygame
from pygame.locals import *
from koboldwizard import *
from time import *
from maproom import *

# each wall has its own pic, for dithered and changed images
class MaproomNorthDungeonWall:
    "Room with a (big) map"
    def __init__(self,x,y):
        self.x = x
        self.y = y
        self.w = 60
        self.h = 48
        self.wallimage = pygame.image.load('./pics/walldungeon1-60x48.bmp')
        
        
    def draw(self,screen,relativex,relativey):
	##print "x=%d" % self.relativex 
        screen.blit(self.wallimage, (self.x+relativex, self.y+relativey))

# Copyright (C) Johan Ceuppens 2010
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


import pygame
from pygame.locals import *
from koboldwizard import *
from time import *
from maproom import *
from maproomdungeonnorthwall import *
from maproomdungeonsouthwall import *
from maproomdungeonwestwall import *
from maproomdungeoneastwall import *

class MaproomDungeon(MaproomBase):
    "Room with a (big) map"
    def __init__(self,x,y):
        MaproomBase.__init__(self,x,y)
        self.northwalls = []
        self.southwalls = []
        self.westwalls = []
        self.eastwalls= []
        self.gameobjects = []
        self.tileboxes = []
        self.pits = []
        
        self.automove = 0
        self.autodirection = "north"
        
    def addnorthwall(self, x,y):
        self.northwalls.append(MaproomNorthDungeonWall(x,y))

    def addsouthwall(self, x,y):
        self.southwalls.append(MaproomSouthDungeonWall(x,y))

    def addwestwall(self, x,y):
        self.westwalls.append(MaproomWestDungeonWall(x,y))

    def addeastwall(self, x,y):
        self.eastwalls.append(MaproomEastDungeonWall(x,y))
        
    def draw(self,screen):
	##print "x=%d" % self.relativex 
        screen.blit(self.background, (0+self.relativex, 0+self.relativey))
        for w in self.northwalls:
            w.draw(screen,self.relativex,self.relativey)
            
##        if self.automove:
##            print 'automove doing'
##            if self.autodirection == "north":
##                self.automovedown()
##            elif self.autodirection == "south":
##                self.automoveup()
##            elif self.autodirection == "west":
##                self.automoveright()
##            elif self.autodirection == "east":
##                self.automoveleft()
##
    def update(self,player):
        if self.automove:
            if player.mousex < player.x:
                self.automoveright()
            if player.mousex > player.x:
                self.automoveleft()
            if player.mousey < player.y:
                self.automovedown()
            if player.mousey > player.y:
                self.automoveup()

    def set_automove(self,player):
        if not player.highlightbase:
            return
        self.automove = 1
        # fall through for diagonal moving
##        if player.mousex < player.x:
##            self.autodirection = 'west'
##        if player.mousex > player.x:
##            self.autodirection = 'east'
##        if player.mousey < player.y:
##            self.autodirection = 'north'
##        if player.mousey > player.y:
##            self.autodirection = 'south'

    def automoveup(self):
	self.prevx = self.relativex
	self.prevy = self.relativey + 1
        self.relativey = self.relativey - 10

    def automovedown(self):
	self.prevx = self.relativex
	self.prevy = self.relativey - 1
        self.relativey = self.relativey + 10

    def automoveleft(self):
	self.prevx = self.relativex + 1
	self.prevy = self.relativey
        self.relativex = self.relativex - 10

    def automoveright(self):
	self.prevx = self.relativex - 1
	self.prevy = self.relativey
        self.relativex = self.relativex + 10
                
# NOTE player can be enemy 
    def collide(self, player):	
	for i in self.gameobjects:
	    if i != None and i.collide(self, player):
		return 2 # 1 kills game
	for i in self.northwalls:
	    if i != None and i.collide(self, player):
		return 2
	for i in self.southwalls:
	    if i != None and i.collide(self, player):
		return 2
	for i in self.westwalls:
	    if i != None and i.collide(self, player):
		return 2
	for i in self.eastwalls:
	    if i != None and i.collide(self, player):
		return 2
	for i in self.tileboxes:
		if i != None and i.collide(self,player):
			self.undomove()
			#player.circumvent(self)
	                # FIXME self.undomove()
			return 2 
	for i in self.pits:
		if i != None and i.collide(self,player):
			return 2
	return 0

    def collidewithenemy(self, enemy):
	for t in self.tileboxes:
		if t != None and t.collidewithenemy(self,enemy):
                    enemy.undomove()
                    return 2 # 1 kills game
        return 0



# Copyright (C) Johan Ceuppens 2010
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


import pygame
from pygame.locals import *
from koboldwizard import *
from time import *
from maproom import *

# each wall has its own pic, for dithered and changed images
class MaproomSouthDungeonWall:
    "Room with a (big) map"
    def __init__(self,x,y):
        self.x = x
        self.y = y
        self.wallimage = pygame.load.image('./pics/walldungeon1-60x48.bmp')
        
        
    def draw(self,screen):
	##print "x=%d" % self.relativex 
        screen.blit(self.wall, (0+self.relativex, 0+self.relativey))

# Copyright (C) Johan Ceuppens 2010
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


import pygame
from pygame.locals import *
from koboldwizard import *
from time import *
from maproom import *

# each wall has its own pic, for dithered and changed images
class MaproomDungeonWall:
    "Room with a (big) map"
    def __init__(self,x,y):
        self.x = x
        self.y = y
        self.wallimage = pygame.image.load('./pics/walldungeon1-60x48.bmp')
        
        
##    def draw(self,screen,self.relativex,self.relativey):
##	##print "x=%d" % self.relativex 
##        screen.blit(self.wallimage, (relativex+self.x, relativey+self.y))

    def collide(self, room, player):
	if (player.x > self.x+room.relativex  and 
	player.x < self.x+room.relativex+self.w and 
	player.y > self.y+room.relativey and 
	player.y < self.y+room.relativey + self.h):
	    print "collision in Dungeon Wall!"	
	    return 1 
	else:
	    return 0

    def collidepickup(self, room, player):
	if (player.x > self.x+room.relativex-self.w  and 
	player.x < self.x+room.relativex+self.w and 
	player.y > self.y+room.relativey-self.h and 
	player.y < self.y+room.relativey + self.h):
	    #print "collision!"	
	    return 1 
	else:
	    return 0 
    
    def collideobjectX(self, room):
	for i in room.gameobjects:
	    if i != None:	
	        if (self.x > i.x  and 
		    self.x < i.x+i.w):
	            return 1 
	return 0

    def collideobjectY(self, room):
	for i in room.gameobjects:
	    if i != None:	
	        if (self.y > i.y  and 
		    self.y < i.y+i.h):
	            return 1 
	return 0
 
    def collideobjectXY(self, room):
	for i in room.gameobjects:
	    if i:		
	        if (self.x > i.x  and 
	 	    self.x < i.x+i.w and 
	            self.y > i.y and 
	            self.y < i.y+i.h):
	            return 1 
	return 0 

# Copyright (C) Johan Ceuppens 2010
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


import pygame
from pygame.locals import *
from koboldwizard import *
from time import *
from maproom import *

# each wall has its own pic, for dithered and changed images
class MaproomWestDungeonWall:
    "Room with a (big) map"
    def __init__(self,x,y):
        self.x = x
        self.y = y
        self.wallimage = pygame.load.image('./pics/walldungeon1-60x48.bmp')
        
        
    def draw(self,screen):
	##print "x=%d" % self.relativex 
        screen.blit(self.wall, (0+self.relativex, 0+self.relativey))

# Copyright (C) Johan Ceuppens 2010
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


import pygame
from pygame.locals import *
from maproom import *
from knight import *
from blackknight import *
from demon import *
from bombman import *
from turtleflying import *
from ghost1 import *
from ghostwandering import *
from ghostcircling import *
from maproom2 import *
from dungeonmasterkey import *
from dungeonkey1 import *
from mithran import *
from innguardian import *

class Maproominn1_3(Maproom):
    "Room with a (big) map - third South of Knight's Castle, Towards Inn Grove"
    def __init__(self,x,y):
        Maproom.__init__(self,x,y)
        self.background = pygame.image.load('./pics/room-bginn1_3.bmp').convert()
        self.gameobjects.append(Tree2(10,20))
	self.gameobjects.append(Tree2(200,70))
	self.gameobjects.append(Tree2(400,10))
        self.guardian = InnGuardian(160,320)
        self.gameobjects.append(self.guardian)
	self.gameobjects.append(Dungeonwall(0,0,100,500))
	self.gameobjects.append(Dungeonwall(200,0,100,500))
	# Inn walls
	self.gameobjects.append(Dungeonwall(0,175,150,400))
	self.gameobjects.append(Dungeonwall(250,250,250,250))
        
    def draw(self,screen):
        screen.blit(self.background, (0+self.relativex, 0+self.relativey))
        for i in self.gameobjects:
	    if i:
                i.draw(screen,self)
 
    def collide(self, player):
	for i in self.gameobjects:
	    if i != None:
		i.update(self)	
	for i in self.gameobjects:
	    if i!= None:
	    	id = i.collide(self,player)
		self.relativex = self.prevx
		self.relativey = self.prevy
		return id
	return 0

    def pickup(self, player):###FIX for each room
        for o in self.gameobjects:
            if (o and o.collide(self, player)):##FIX o.colidepickup
                id = o.pickup(self)
                self.dungeonkey1 = 1
		return id
        return 0
    
    def exit(self, game):
        # FIX
	return 0

    def removeobject(self, o):
        for i in (0,len(self.gameobjects)-1):
            print "o=%s self.gameobjects[i]=%s i=%d" % (o,self.gameobjects[i],i)
            if self.gameobjects[i] == o:
                print "PICKUP or die"
                self.gameobjects[i] = None
		return 

    def collidesword(self,room,player):
        for i in self.gameobjects:
	    if i!= None:
	    	c = i.collide(room,player)
	    	print "i=%s" % i
		if c == 1:
                        print "collision with i=%s!" % i
			return i ## NOTE : returns collided entity (single)
		self.relativex = self.prevx
		self.relativey = self.prevy
	return None

    def isroomdownexit(self):
	if self.relativey < - 200:### and self.relativey < 20:
		return 1
	return 0
	
    def exit(self, game):
##        print "x=%d y=%d" % (self.relativex,self.relativey)
##        if self.isroomupexit():
##	    self.setxyfromup()	    
##	    return 1
	if self.isroomdownexit():
	    self.setxyfromdown()	    
	    return 1.4
	if self.isroomupexit():
	    self.setxyfromup()	    
	    return 1.2
##	#Trap door: elif self.isroomdownexit():
##	#    self.setxyfromdown()	
##	#    return 11
##	else:
	return 0

    def talkto(self):#FIXME needs font
            print "talk to in maproom 1_3"
            ## return self.koboldwiz
            self.guardian.talkcounter = 1
            return self.guardian

# Copyright (C) Johan Ceuppens 2010
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


import pygame
from pygame.locals import *
from maproom import *
from knight import *
from blackknight import *
from demon import *
from bombman import *
from turtleflying import *
from ghost1 import *
from ghostwandering import *
from ghostcircling import *
from maproom2 import *
from dungeonmasterkey import *
from dungeonkey1 import *
from mithran import *
from innguardian2 import *

class Maproominn1_4(Maproom):
    "Room with a (big) map - Inside Inn"
    def __init__(self,x,y):
        Maproom.__init__(self,x,y)
        self.background = pygame.image.load('./pics/room-bginn1_4.bmp').convert()
##        self.gameobjects.append(Tree2(10,200))
##	self.gameobjects.append(Tree2(200,170))
##	self.gameobjects.append(Tree2(400,210))
	self.gameobjects.append(Dungeonwall(0,0,600,50))
	self.gameobjects.append(Dungeonwall(0,0,50,600))
	self.gameobjects.append(Dungeonwall(550,0,50,600))
	self.gameobjects.append(Dungeonwall(0,550,600,50))
	self.guardian = InnGuardian2(460,140)
        self.gameobjects.append(self.guardian)
	# Inn walls
	#self.gameobjects.append(Dungeonwall(0,300,500,100))
        
        
    def draw(self,screen):
        screen.blit(self.background, (0+self.relativex, 0+self.relativey))
        for i in self.gameobjects:
	    if i:
                i.draw(screen,self)
 
    def collide(self, player):
	for i in self.gameobjects:
	    if i != None:
		i.update(self)	
	for i in self.gameobjects:
	    if i!= None:
	    	id = i.collide(self,player)
		self.relativex = self.prevx
		self.relativey = self.prevy
		return id
	return 0

    def pickup(self, player):###FIX for each room
        for o in self.gameobjects:
            if (o and o.collide(self, player)):##FIX o.colidepickup
                id = o.pickup(self)
                self.dungeonkey1 = 1
		return id
        return 0
    
    def removeobject(self, o):
        for i in (0,len(self.gameobjects)-1):
            print "o=%s self.gameobjects[i]=%s i=%d" % (o,self.gameobjects[i],i)
            if self.gameobjects[i] == o:
                print "PICKUP or die"
                self.gameobjects[i] = None
		return 

    def collidesword(self,room,player):
        for i in self.gameobjects:
	    if i!= None:
	    	c = i.collide(room,player)
	    	print "i=%s" % i
		if c == 1:
                        print "collision with i=%s!" % i
			return i ## NOTE : returns collided entity (single)
		self.relativex = self.prevx
		self.relativey = self.prevy
	return None

    def setxyfromdoor(self):
        self.relativex = -150
        self.relativey = -250
    
    def isroomdoorexit(self):
	if self.relativex < -50 and self.relativex > -100 and self.relativey > -280 and self.relativey < -240:
            return 1
        return 0
    
    def exit(self, game):
        print "x=%d y=%d" % (self.relativex,self.relativey)
        if self.isroomupexit():
	    self.setxyfromup()	    
	    return 1.3
	elif self.isroomdoorexit():
            self.setxyfromdoor()
            return 1.5            
##	elif self.isroomdownexit():
##	    self.setxyfromdown()	    
##	    return 1.2
##	#Trap door: elif self.isroomdownexit():
##	#    self.setxyfromdown()	
##	#    return 11
##	else:
	return 0

    def talkto(self):#FIXME needs font
            print "talk to in maproom 1_3"
            ## return self.koboldwiz
            self.guardian.talkcounter = 1
            return self.guardian

# Copyright (C) Johan Ceuppens 2010
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


import pygame
from pygame.locals import *
from maproom import *
from knight import *
from blackknight import *
from demon import *
from bombman import *
from turtleflying import *
from ghost1 import *
from ghostwandering import *
from ghostcircling import *
from maproom2 import *
from dungeonmasterkey import *
from dungeonkey1 import *
from mithran import *
from innguardian2 import *
from roadsigninn import *

from butterfly import *
from butterfly2 import *

class Maproominn1_4(Maproom):
    "Room with a (big) map - Inside Inn"
    def __init__(self,x,y):
        Maproom.__init__(self,x,y)
        self.background = pygame.image.load('./pics/room-bginn1_4.bmp').convert()
        # Inn walls
	self.gameobjects.append(Dungeonwall(200,0,200,100))
        # Rooms + Barracks
	self.gameobjects.append(Dungeonwall(200,250,300,100))
	# Trees etc.
        self.gameobjects.append(Tree2(10,200))
	self.gameobjects.append(Tree2(200,170))
	self.gameobjects.append(Tree2(100,410))
	self.gameobjects.append(Dungeonwall(0,0,600,50))
	self.gameobjects.append(Dungeonwall(0,0,50,600))
	self.gameobjects.append(Dungeonwall(550,0,50,600))
	self.gameobjects.append(Dungeonwall(0,550,600,50))
	self.guardian = InnGuardian2(300,140)
        self.gameobjects.append(self.guardian)

        self.gameobjects.append(RoadSignInn(200,100))
        
        self.gameobjects.append(Butterfly(100,100))
        self.gameobjects.append(Butterfly2(500,100))
        self.gameobjects.append(Butterfly2(300,400))
        
    def draw(self,screen):
        screen.blit(self.background, (0+self.relativex, 0+self.relativey))
        for i in self.gameobjects:
	    if i:
                i.draw(screen,self)
 
    def collide(self, player):
	for i in self.gameobjects:
	    if i != None:
		i.update(self)	
	for i in self.gameobjects:
	    if i!= None:
	    	id = i.collide(self,player)
		self.relativex = self.prevx
		self.relativey = self.prevy
		return id
	return 0

    def pickup(self, player):###FIX for each room
        for o in self.gameobjects:
            if (o and o.collide(self, player)):##FIX o.colidepickup
                id = o.pickup(self)
                self.dungeonkey1 = 1
		return id
        return 0
    
    def removeobject(self, o):
        for i in (0,len(self.gameobjects)-1):
            print "o=%s self.gameobjects[i]=%s i=%d" % (o,self.gameobjects[i],i)
            if self.gameobjects[i] == o:
                print "PICKUP or die"
                self.gameobjects[i] = None
		return 

    def collidesword(self,room,player):
        for i in self.gameobjects:
	    if i!= None:
	    	c = i.collide(room,player)
	    	print "i=%s" % i
		if c == 1:
                        print "collision with i=%s!" % i
			return i ## NOTE : returns collided entity (single)
		self.relativex = self.prevx
		self.relativey = self.prevy
	return None

    def setxyfromdoor(self):
        self.relativex = 0
        self.relativey = -100
    
    def isroomdoorexit(self):
	if self.relativex < -140 and self.relativex > -188 and self.relativey > 30 and self.relativey < 50:
            return 1
        return 0

    def setxyfromup(self):
        self.relativex = -60
        self.relativey = -110
    
    def isroomupexit(self):
	if self.relativex > 0 and self.relativex < 100 and self.relativey > 100:
            return 1
        return 0
    
    def exit(self, game):
        if self.isroomupexit():
	    self.setxyfromup()	    
	    return 1.3
	elif self.isroomdoorexit():
            self.setxyfromdoor()
            return 1.5            
	return 0

    def talkto(self):#FIXME needs font
            print "talk to in maproom 1_3"
            ## return self.koboldwiz
            self.guardian.talkcounter = 1
            return self.guardian

# Copyright (C) Johan Ceuppens 2010
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


import pygame
from pygame.locals import *
from maproom import *
from knight import *
from blackknight import *
from demon import *
from bombman import *
from turtleflying import *
from ghost1 import *
from ghostwandering import *
from ghostcircling import *
from maproom2 import *
from dungeonmasterkey import *
from dungeonkey1 import *
from mithran import *
from innguardian3 import *
from inndoor import *

class Maproominn1_5(Maproom):
    "Room with a (big) map - Inside Inn"
    def __init__(self,x,y):
        Maproom.__init__(self,x,y)
        self.background = pygame.image.load('./pics/room-bginn1_5.bmp').convert()
        # Inn upper walls
	self.gameobjects.append(Dungeonwall(0,0,160,200))
	self.gameobjects.append(Dungeonwall(0,0,320,120))
	self.gameobjects.append(Dungeonwall(400,300,300,100))
	self.gameobjects.append(Dungeonwall(500,0,200,500))
        # Inn lower walls
        self.gameobjects.append(Dungeonwall(0,300,160,200))
        self.gameobjects.append(Dungeonwall(0,400,500,700))
        self.gameobjects.append(Dungeonwall(440,280,260,220))
        # Inn table
        self.gameobjects.append(Dungeonwall(220,180,160,220))
        # door
        self.gameobjects.append(InnDoor(320,25))
        # guardian
        self.guardian = InnGuardian3(460,90)
        self.gameobjects.append(self.guardian)
        
    def draw(self,screen):
        screen.blit(self.background, (0+self.relativex, 0+self.relativey))
        for i in self.gameobjects:
	    if i:
                i.draw(screen,self)
 
    def collide(self, player):
	for i in self.gameobjects:
	    if i != None:
		i.update(self)	
	for i in self.gameobjects:
	    if i!= None:
	    	id = i.collide(self,player)
		self.relativex = self.prevx
		self.relativey = self.prevy
		return id
	return 0

    def pickup(self, player):###FIX for each room
        for o in self.gameobjects:
            if (o and o.collide(self, player)):##FIX o.colidepickup
                id = o.pickup(self)
                self.dungeonkey1 = 1
		return id
        return 0
    
    def exit(self, game):
        # FIX
	return 0

    def removeobject(self, o):
        for i in (0,len(self.gameobjects)-1):
            print "o=%s self.gameobjects[i]=%s i=%d" % (o,self.gameobjects[i],i)
            if self.gameobjects[i] == o:
                print "PICKUP or die"
                self.gameobjects[i] = None
		return 

    def collidesword(self,room,player):
        for i in self.gameobjects:
	    if i!= None:
	    	c = i.collide(room,player)
	    	print "i=%s" % i
		if c == 1:
                        print "collision with i=%s!" % i
			return i ## NOTE : returns collided entity (single)
		self.relativex = self.prevx
		self.relativey = self.prevy
	return None

    def setxyfromdoor(self):
        self.relativex = -50
        self.relativey = -350
    
    def isroomdoorexit(self):
	if self.relativex < -140 and self.relativex > -190 and self.relativey > -250 and self.relativey < -230:
            return 1
        return 0

    def setxyfromdoor2(self):
        self.relativex = 0
        self.relativey = 0
    
    def isroomdoorexit2(self):
	if self.relativey > 100:
            return 1
        return 0
    
    def exit(self, game):
        print "x=%d y=%d" % (self.relativex,self.relativey)
	if self.isroomdoorexit():
            self.setxyfromdoor()
            return 1.4
        elif self.isroomdoorexit2():
            self.setxyfromdoor2()
            return 1.6  
##	elif self.isroomdownexit():
##	    self.setxyfromdown()	    
##	    return 1.2
##	#Trap door: elif self.isroomdownexit():
##	#    self.setxyfromdown()	
##	#    return 11
##	else:
	return 0

    def talkto(self):#FIXME needs font
            print "talk to in maproom 1_3"
            ## return self.koboldwiz
            self.guardian.talkcounter = 1
            return self.guardian

# Copyright (C) Johan Ceuppens 2010
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


import pygame
from pygame.locals import *
from maproom import *
from knight import *
from blackknight import *
from demon import *
from bombman import *
from turtleflying import *
from ghost1 import *
from ghostwandering import *
from ghostcircling import *
from maproom2 import *
from dungeonmasterkey import *
from dungeonkey1 import *
from yuaninnkeeper import *
from rubysword import *

class Maproominn1_5(Maproom):
    "Room with a (big) map"
    def __init__(self,x,y):
        Maproom.__init__(self,x,y)
        self.background = pygame.image.load('./pics/room-bginn1_5.bmp').convert()
        ###	self.gameobjects.append(Bombman(100,50))
###	self.gameobjects.append(Bombman(200,100))
###	self.gameobjects.append(Bombman(100,150))
        self.yuan = YuanInnKeeper(110,120)
	self.gameobjects.append(self.yuan)
	self.gameobjects.append(Dungeonwall(0,0,300,100))
	self.gameobjects.append(Dungeonwall(200,0,100,300))
	self.gameobjects.append(Dungeonwall(0,0,100,300))
	self.gameobjects.append(Dungeonwall(0,200,300,100))
	self.gameobjects.append(RubySword(160,100))
	     
    def draw(self,screen):
        screen.blit(self.background, (0+self.relativex, 0+self.relativey))
        for i in self.gameobjects:
	    if i:
                i.draw(screen,self)
 
    def collide(self, player):
	for i in self.gameobjects:
	    if i != None:
		i.update(self)	
	for i in self.gameobjects:
	    if i!= None:
	    	id = i.collide(self,player)
		self.relativex = self.prevx
		self.relativey = self.prevy
		return id
	return 0

    def pickup(self, player):###FIX for each room
        for o in self.gameobjects:
            if (o and o.collide(self, player)):##FIX o.colidepickup
                id = o.pickup(self)
                self.dungeonkey1 = 1
		return id
        return 0
    
    def exit(self, game):
        # FIX
	return 0

    def removeobject(self, o):
        for i in (0,len(self.gameobjects)-1):
            print "o=%s self.gameobjects[i]=%s i=%d" % (o,self.gameobjects[i],i)
            if self.gameobjects[i] == o:
                print "PICKUP or die"
                self.gameobjects[i] = None
		return 

    def collidesword(self,room,player):
        for i in self.gameobjects:
	    if i!= None:
	    	c = i.collide(room,player)
	    	print "i=%s" % i
		if c == 1:
                        print "collision with i=%s!" % i
			return i ## NOTE : returns collided entity (single)
		self.relativex = self.prevx
		self.relativey = self.prevy
	return None

    def isroomhouseexit(self):
	if self.relativex  < 60 and self.relativex > -10 and self.relativey < -70 and self.relativey > - 130:### and self.relativey < 20:
		return 1
	return 0

    def setxyfromhouse(self):
        self.relativex = -600
	self.relativey = -500
	
	
    def exit(self, game):
        if self.isroomhouseexit():
	    self.setxyfromhouse()	    
	    return 1.4
	#Trap door: elif self.isroomdownexit():
	#    self.setxyfromdown()	
	#    return 11
	else:
	    return 0


    def talkto(self):#FIXME needs font
            print "talk to in maproom 6"
            ## return self.koboldwiz
            self.yuan.talkcounter = 1 # FIXME public var
            return self.yuan

# Copyright (C) Johan Ceuppens 2010
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


import pygame
from pygame.locals import *
from maproom import *
from knight import *
from blackknight import *
from demon import *
from bombman import *
from turtleflying import *
from ghost1 import *
from ghostwandering import *
from ghostcircling import *
from maproom2 import *
from dungeonmasterkey import *
from dungeonkey1 import *
from mithran import *
from yuaninnkeeper import *

class Maproominn1_6(Maproom):
    "Room with a (big) map - Inside Inn 2nd room"
    def __init__(self,x,y):
        Maproom.__init__(self,x,y)
        self.background = pygame.image.load('./pics/room-bginn1_6.bmp').convert()
        # Inn upper walls
	self.gameobjects.append(Dungeonwall(0,0,400,100))
	self.gameobjects.append(Dungeonwall(0,0,20,400))
	self.gameobjects.append(Dungeonwall(400,0,20,400))
        self.yuan = YuanInnKeeper(100,130)
        self.gameobjects.append(self.yuan)
        
    def draw(self,screen):
        screen.blit(self.background, (0+self.relativex, 0+self.relativey))
        for i in self.gameobjects:
	    if i:
                i.draw(screen,self)
 
    def collide(self, player):
	for i in self.gameobjects:
	    if i != None:
		i.update(self)	
	for i in self.gameobjects:
	    if i!= None:
	    	id = i.collide(self,player)
		self.relativex = self.prevx
		self.relativey = self.prevy
		return id
	return 0

    def pickup(self, player):###FIX for each room
        for o in self.gameobjects:
            if (o and o.collide(self, player)):##FIX o.colidepickup
                id = o.pickup(self)
                self.dungeonkey1 = 1
		return id
        return 0
    
    def exit(self, game):
        # FIX
	return 0

    def removeobject(self, o):
        for i in (0,len(self.gameobjects)-1):
            print "o=%s self.gameobjects[i]=%s i=%d" % (o,self.gameobjects[i],i)
            if self.gameobjects[i] == o:
                print "PICKUP or die"
                self.gameobjects[i] = None
		return 

    def collidesword(self,room,player):
        for i in self.gameobjects:
	    if i!= None:
	    	c = i.collide(room,player)
	    	print "i=%s" % i
		if c == 1:
                        print "collision with i=%s!" % i
			return i ## NOTE : returns collided entity (single)
		self.relativex = self.prevx
		self.relativey = self.prevy
	return None

    def setxyfromdoor(self):
        self.relativex = -50
        self.relativey = -350
    
    def isroomdoorexit(self):
	if self.relativey < 0:
            return 1
        return 0
    
    def exit(self, game):
        print "x=%d y=%d" % (self.relativex,self.relativey)
	if self.isroomdoorexit():
            self.setxyfromdoor()
            return 1.5          
##	elif self.isroomdownexit():
##	    self.setxyfromdown()	    
##	    return 1.2
##	#Trap door: elif self.isroomdownexit():
##	#    self.setxyfromdown()	
##	#    return 11
##	else:
	return 0

    def talkto(self):#FIXME needs font
            print "talk to in maproom inn 1_6"
            ## return self.koboldwiz
            self.yuan.talkcounter = 1
            return self.yuan

# Copyright (C) Johan Ceuppens 2010
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


import pygame
from pygame.locals import *
from maproom import *
from knight import *
from blackknight import *
from demon import *
from bombman import *
from turtleflying import *
from ghost1 import *
from ghostwandering import *
from ghostcircling import *
from maproom2 import *
from dungeonmasterkey import *
from dungeonkey1 import *
from mithran import *
from yuaninnkeeper import *

class Maproominn1_6(Maproom):
    "Room with a (big) map - Inside Inn 2nd room"
    def __init__(self,x,y):
        Maproom.__init__(self,x,y)
        self.background = pygame.image.load('./pics/room-bginn1_6.bmp').convert()
        # Inn upper walls
	self.gameobjects.append(Dungeonwall(0,0,400,100))
	self.gameobjects.append(Dungeonwall(0,0,20,400))
	self.gameobjects.append(Dungeonwall(400,0,20,400))
        self.yuan = YuanInnKeeper(100,130)
        self.gameobjects.append(self.yuan)
        
    def draw(self,screen):
        screen.blit(self.background, (0+self.relativex, 0+self.relativey))
        for i in self.gameobjects:
	    if i:
                i.draw(screen,self)
 
    def collide(self, player):
	for i in self.gameobjects:
	    if i != None:
		i.update(self)	
	for i in self.gameobjects:
	    if i!= None:
	    	id = i.collide(self,player)
		self.relativex = self.prevx
		self.relativey = self.prevy
		return id
	return 0

    def pickup(self, player):###FIX for each room
        for o in self.gameobjects:
            if (o and o.collide(self, player)):##FIX o.colidepickup
                id = o.pickup(self)
                self.dungeonkey1 = 1
		return id
        return 0
    
    def exit(self, game):
        # FIX
	return 0

    def removeobject(self, o):
        for i in (0,len(self.gameobjects)-1):
            print "o=%s self.gameobjects[i]=%s i=%d" % (o,self.gameobjects[i],i)
            if self.gameobjects[i] == o:
                print "PICKUP or die"
                self.gameobjects[i] = None
		return 

    def collidesword(self,room,player):
        for i in self.gameobjects:
	    if i!= None:
	    	c = i.collide(room,player)
	    	print "i=%s" % i
		if c == 1:
                        print "collision with i=%s!" % i
			return i ## NOTE : returns collided entity (single)
		self.relativex = self.prevx
		self.relativey = self.prevy
	return None

    def setxyfromdoor(self):
        self.relativex = -50
        self.relativey = -350
    
    def isroomdoorexit(self):
	if self.relativey < 0:
            return 1
        return 0
    
    def exit(self, game):
        print "x=%d y=%d" % (self.relativex,self.relativey)
	if self.isroomdoorexit():
            self.setxyfromdoor()
            return 1.5          
##	elif self.isroomdownexit():
##	    self.setxyfromdown()	    
##	    return 1.2
##	#Trap door: elif self.isroomdownexit():
##	#    self.setxyfromdown()	
##	#    return 11
##	else:
	return 0

    def talkto(self):#FIXME needs font
            print "talk to in maproom inn 1_6"
            ## return self.koboldwiz
            self.yuan.talkcounter = 1
            return self.yuan

# Copyright (C) Johan Ceuppens 2010
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


import pygame
from pygame.locals import *
from koboldwizard import *
from time import *
from maproombase import *

class Maproom(MaproomBase):
    "Room with a (big) map"
    def __init__(self,x,y):
        MaproomBase.__init__(self,x,y)
        self.gameobjects = []
        ### NOTE all items which can only pickup once (see maproomXXX.py)
        self.dungeonkey1 = 0
        self.dungeonkey2 = 0
        self.masterkey = 0

        
    def draw(self,screen):
	##print "x=%d" % self.relativex 
        screen.blit(self.background, (0+self.relativex, 0+self.relativey))

    def pickup(self, player):
        return 0

    def undomove(self):
        if self.direction == "north":
            self.movedown()
            self.movedown()
        elif self.direction == "south":
            self.moveup()
            self.moveup()
        elif self.direction == "west":
            self.moveright()
            self.moveright()
        elif self.direction == "east":
            self.moveleft()
            self.moveleft()
 
    def moveup(self):
        self.direction = "north"
	self.prevx = self.relativex
	self.prevy = self.relativey + 10
        self.relativey = self.relativey - 10

    def movedown(self):
        self.direction = "south"
	self.prevx = self.relativex
	self.prevy = self.relativey - 10
        self.relativey = self.relativey + 10

    def moveleft(self):
        self.direction = "west"
	self.prevx = self.relativex + 10
	self.prevy = self.relativey
        self.relativex = self.relativex - 10

    def moveright(self):
        self.direction = "east"
	self.prevx = self.relativex - 10
	self.prevy = self.relativey
        self.relativex = self.relativex + 10

        
    def setxyfromleft(self):
        self.relativex = 0 
        self.relativey = 100

    def isroomleftexit(self):
	if self.relativex > 100 and self.relativey > -10:#FIX and self.relativey < -10 - 48:
		return 1
	return 0

    def setxyfromright(self):
        self.relativex = 100 
        self.relativey = 0

    def isroomrightexit(self):
	if self.relativex < -110 and self.relativey > -10:
		return 1
	return 0

    def setxyfromup(self):
        self.relativex = 0 
        self.relativey = -100

    def isroomupexit(self):
	if self.relativex >= 0 and self.relativey > 100 and self.relativey < 200:
		return 1
	return 0

    def setxyfromdown(self):
        self.relativex = 0 
        self.relativey = -100

    def isroomdownexit(self):
	if self.relativex  >= 0 and self.relativex <= 80 and self.relativey < -80:### and self.relativey < 20:
		return 1
	return 0

    def removeobject(self, o):
        for i in self.gameobjects:
	    if i!= None:
                if i == o:
                    i = None ###FIXME2

    def talkto(self):
        return None

    def collidesword(self,room,player):
        for i in self.gameobjects:
	    if i!= None:
	    	id = i.collide(room,player)
                ##self.relativex = self.prevx
		##self.relativey = self.prevy
		return i ## NOTE : returns collided entity (single)
	return None

    def hitwithsword(self, o):
        hitp = o.hit()
        if hitp < 0:
            self.removeobject(o)

# Copyright (C) Johan Ceuppens 2010
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


import pygame
from pygame.locals import *

class Heart:
	def __init__(self):
        	self.image = pygame.image.load('./pics/life3.bmp').convert()
        	self.image.set_colorkey((0,0,0)) 
		

class Meter:
    "life or mana meter"
    def __init__(self):
	self.max = 50 
	self.index = 50
	self.hearts = []
	for i in range(0,3):
		self.hearts.append(Heart())

    def setmax(self, m):
            self.max = m
 
    def draw(self,screen):
	# KLUDGY
	j = 0
	for i in range(0,self.index):
        	screen.blit(self.hearts[0].image, (0+j*1, 340))
		j += 1

    def drawat(self,screen,x,y):
	# KLUDGY
	j = 0
	for i in range(0,self.index):
        	screen.blit(self.hearts[0].image, (x+j*1, y))
		j += 1

# Copyright (C) Johan Ceuppens 2010
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


import pygame
from pygame.locals import *
from gameobject import *
from stateimagelibrary import *
import random
from time import *

class Mithran2(Gameobject):
    "BlackKnight"
    def __init__(self,xx,yy):
	Gameobject.__init__(self, xx, yy)
        self.w = 48
        self.h = 48 
	self.stimlibdown = Stateimagelibrary()	
	self.stimlibup = Stateimagelibrary()	
        image = pygame.image.load('./pics/mithran1-48x48.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibdown.addpicture(image)	
        image = pygame.image.load('./pics/mithran1-48x48.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibdown.addpicture(image)
	image = pygame.image.load('./pics/mithran1-48x48.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibdown.addpicture(image)
	image = pygame.image.load('./pics/mithran1-48x48.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibdown.addpicture(image)

	image = pygame.image.load('./pics/mithran2-48x48.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibdown.addpicture(image)	
        image = pygame.image.load('./pics/mithran2-48x48.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibdown.addpicture(image)
	image = pygame.image.load('./pics/mithran2-48x48.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibdown.addpicture(image)
	image = pygame.image.load('./pics/mithran2-48x48.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibdown.addpicture(image)

        image = pygame.image.load('./pics/mithran3-48x48.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibdown.addpicture(image)	
        image = pygame.image.load('./pics/mithran3-48x48.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibdown.addpicture(image)
	image = pygame.image.load('./pics/mithran3-48x48.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibdown.addpicture(image)
	image = pygame.image.load('./pics/mithran3-48x48.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibdown.addpicture(image)

        image = pygame.image.load('./pics/mithran2-48x48.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibdown.addpicture(image)	
        image = pygame.image.load('./pics/mithran2-48x48.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibdown.addpicture(image)
	image = pygame.image.load('./pics/mithran2-48x48.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibdown.addpicture(image)
	image = pygame.image.load('./pics/mithran2-48x48.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibdown.addpicture(image)

        image = pygame.image.load('./pics/mithranup1-48x48.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibup.addpicture(image)
	image = pygame.image.load('./pics/mithranup1-48x48.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibup.addpicture(image)
	image = pygame.image.load('./pics/mithranup1-48x48.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibup.addpicture(image)
	image = pygame.image.load('./pics/mithranup1-48x48.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibup.addpicture(image)

	image = pygame.image.load('./pics/mithranup2-48x48.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibup.addpicture(image)
	image = pygame.image.load('./pics/mithranup2-48x48.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibup.addpicture(image)
	image = pygame.image.load('./pics/mithranup2-48x48.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibup.addpicture(image)
	image = pygame.image.load('./pics/mithranup2-48x48.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibup.addpicture(image)

	image = pygame.image.load('./pics/mithranup3-48x48.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibup.addpicture(image)
	image = pygame.image.load('./pics/mithranup3-48x48.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibup.addpicture(image)
	image = pygame.image.load('./pics/mithranup3-48x48.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibup.addpicture(image)
	image = pygame.image.load('./pics/mithranup3-48x48.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibup.addpicture(image)
        	
        image = pygame.image.load('./pics/mithranup2-48x48.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibup.addpicture(image)
	image = pygame.image.load('./pics/mithranup2-48x48.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibup.addpicture(image)
	image = pygame.image.load('./pics/mithranup2-48x48.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibup.addpicture(image)
	image = pygame.image.load('./pics/mithranup2-48x48.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibup.addpicture(image)

	self.talkcounter = 0
	self.direction = "down"

    def draw(self, screen, room):
	if (self.direction == "down"):
            self.stimlibdown.draw(screen, self.x+room.relativex,self.y+room.relativey)
	elif (self.direction == "up"):
            self.stimlibup.draw(screen, self.x+room.relativex,self.y+room.relativey)
	    
	     
    def update(self,room):
        sleep(.04) # FIX mithran sleep
	
	if (not self.collideobjectY(room)): 
	    if (self.direction == "down"):
	        self.y -=2
	        self.direction = "up" 
	    elif (self.direction == "up"):
	        self.y +=2
	        self.direction = "down"

	if (self.direction == "up"):
	        self.y -=1 
	elif (self.direction == "down"):
	        self.y +=1

    def collide(self, room, player):
        
	if (player.x > self.x+room.relativex  and 
	player.x < self.x+room.relativex+self.w and 
	player.y > self.y+room.relativey and 
	player.y < self.y+room.relativey + self.h):
	    print "collision with Mithran!"
	    return 2 
	else:
	    return 0 ## for game self.talker

		 
    def talk(self, screen,font):
        if self.talkcounter == 0:
            return
        
        if self.talkcounter > 2:
                self.talkcounter = 0
                return 
        talkover = 0
        while talkover == 0:
            pygame.display.update()
            if self.talkcounter == 1:
                screen.blit(font.render("Welcome.", 8, (255,255,255)), (10,100))
            elif self.talkcounter == 2:
                screen.blit(font.render("Anything is good.", 8, (255,255,255)), (10,100))
            for event in pygame.event.get():
                if event.type == QUIT:
                    return
                elif event.type == KEYDOWN:
                    if event.key == K_z:
                        talkover = 1
                        self.talkcounter += 1
                

# Copyright (C) Johan Ceuppens 2010 
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


import pygame
from pygame.locals import *
from gameobject import *

class Mithranhouse(Gameobject):
    "Mithran's house"
    def __init__(self, xx,yy,ww,hh):
        Gameobject.__init__(self,xx,yy)
        self.w = ww
        self.h = hh 
        self.image = pygame.image.load('./pics/mithranhouse1.1-200x200.bmp').convert()
        self.image.set_colorkey((0,0,0)) 

    def collide(self, room, player):
	if (player.x > self.x+room.relativex  and 
	player.x < self.x+room.relativex+self.w and 
	player.y > self.y+room.relativey and 
	player.y < self.y+room.relativey + self.h):
	    print "collision in box!"	
	    return 2 
	else:
	    return 0

# Copyright (C) Johan Ceuppens 2010
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


import pygame
from pygame.locals import *
from gameobject import *
from stateimagelibrary import *
import random
from time import *

class Mithran(Gameobject):
    "BlackKnight"
    def __init__(self,xx,yy):
	Gameobject.__init__(self, xx, yy)
        self.w = 48
        self.h = 48 
	self.stimlibdown = Stateimagelibrary()	
	self.stimlibup = Stateimagelibrary()	
        image = pygame.image.load('./pics/mithran1-48x48.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibdown.addpicture(image)	
        image = pygame.image.load('./pics/mithran1-48x48.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibdown.addpicture(image)
	image = pygame.image.load('./pics/mithran1-48x48.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibdown.addpicture(image)
	image = pygame.image.load('./pics/mithran1-48x48.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibdown.addpicture(image)

	image = pygame.image.load('./pics/mithran2-48x48.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibdown.addpicture(image)	
        image = pygame.image.load('./pics/mithran2-48x48.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibdown.addpicture(image)
	image = pygame.image.load('./pics/mithran2-48x48.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibdown.addpicture(image)
	image = pygame.image.load('./pics/mithran2-48x48.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibdown.addpicture(image)

        image = pygame.image.load('./pics/mithran3-48x48.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibdown.addpicture(image)	
        image = pygame.image.load('./pics/mithran3-48x48.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibdown.addpicture(image)
	image = pygame.image.load('./pics/mithran3-48x48.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibdown.addpicture(image)
	image = pygame.image.load('./pics/mithran3-48x48.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibdown.addpicture(image)

        image = pygame.image.load('./pics/mithran2-48x48.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibdown.addpicture(image)	
        image = pygame.image.load('./pics/mithran2-48x48.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibdown.addpicture(image)
	image = pygame.image.load('./pics/mithran2-48x48.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibdown.addpicture(image)
	image = pygame.image.load('./pics/mithran2-48x48.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibdown.addpicture(image)

        image = pygame.image.load('./pics/mithranup1-48x48.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibup.addpicture(image)
	image = pygame.image.load('./pics/mithranup1-48x48.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibup.addpicture(image)
	image = pygame.image.load('./pics/mithranup1-48x48.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibup.addpicture(image)
	image = pygame.image.load('./pics/mithranup1-48x48.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibup.addpicture(image)

	image = pygame.image.load('./pics/mithranup2-48x48.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibup.addpicture(image)
	image = pygame.image.load('./pics/mithranup2-48x48.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibup.addpicture(image)
	image = pygame.image.load('./pics/mithranup2-48x48.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibup.addpicture(image)
	image = pygame.image.load('./pics/mithranup2-48x48.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibup.addpicture(image)

	image = pygame.image.load('./pics/mithranup3-48x48.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibup.addpicture(image)
	image = pygame.image.load('./pics/mithranup3-48x48.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibup.addpicture(image)
	image = pygame.image.load('./pics/mithranup3-48x48.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibup.addpicture(image)
	image = pygame.image.load('./pics/mithranup3-48x48.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibup.addpicture(image)
        	
        image = pygame.image.load('./pics/mithranup2-48x48.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibup.addpicture(image)
	image = pygame.image.load('./pics/mithranup2-48x48.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibup.addpicture(image)
	image = pygame.image.load('./pics/mithranup2-48x48.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibup.addpicture(image)
	image = pygame.image.load('./pics/mithranup2-48x48.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibup.addpicture(image)

	self.talkcounter = 0
	self.direction = "down"

    def draw(self, screen, room):
	if (self.direction == "down"):
            self.stimlibdown.draw(screen, self.x+room.relativex,self.y+room.relativey)
	elif (self.direction == "up"):
            self.stimlibup.draw(screen, self.x+room.relativex,self.y+room.relativey)
	    
	     
    def update(self,room):
        sleep(.04) # FIX mithran sleep
	
	if (not self.collideobjectY(room)): 
	    if (self.direction == "down"):
	        self.y -=2
	        self.direction = "up" 
	    elif (self.direction == "up"):
	        self.y +=2
	        self.direction = "down"

	if (self.direction == "up"):
	        self.y -=1 
	elif (self.direction == "down"):
	        self.y +=1

    def collide(self, room, player):
        
	if (player.x > self.x+room.relativex  and 
	player.x < self.x+room.relativex+self.w and 
	player.y > self.y+room.relativey and 
	player.y < self.y+room.relativey + self.h):
	    print "collision with Mithran!"
	    return 2 
	else:
	    return 0 ## for game self.talker

		 
    def talk(self, screen,font):
        if self.talkcounter == 0:
            return
        
        if self.talkcounter > 2:
                self.talkcounter = 0
                return 
        talkover = 0
        while talkover == 0:
            pygame.display.update()
            if self.talkcounter == 1:
                screen.blit(font.render("I am Mithran.", 8, (255,255,255)), (10,100))
            elif self.talkcounter == 2:
                screen.blit(font.render("I live further north of here.", 8, (255,255,255)), (10,100))
            for event in pygame.event.get():
                if event.type == QUIT:
                    return
                elif event.type == KEYDOWN:
                    if event.key == K_z:
                        talkover = 1
                        self.talkcounter += 1
                

# Copyright (C) Johan Ceuppens 2010
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


import pygame
from pygame.locals import *
from gameobject import *
from stateimagelibrary import *
import random

class Mongbat(Gameobject):
    ""
    def __init__(self,xx,yy):
	Gameobject.__init__(self, xx, yy)
        self.w = 64
        self.h = 64 
	self.stimlibleft = Stateimagelibrary()	
	self.stimlibright = Stateimagelibrary()	
        image = pygame.image.load('./pics/mongbat1-24x24.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)	
        image = pygame.image.load('./pics/mongbat1-24x24.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibright.addpicture(image)	
	self.direction = "left"

    def draw(self, screen, room):
	if (self.direction == "left"):
            self.stimlibleft.draw(screen, self.x+room.relativex,self.y+room.relativey)
	elif (self.direction == "right"):
            self.stimlibright.draw(screen, self.x+room.relativex,self.y+room.relativey)
	    
	     
    def update(self,room):
##        self.x-=1
##	if (random.randint(0,100) == 0 and self.direction == "left"):
##	   self.direction = "right"
##	elif (random.randint(0,100) == 0 and self.direction == "right"):
##	   self.direction = "left"
##
	if (not self.collideobjectX(room)): 
	    if (self.direction == "left"):
	        self.x +=2
	        self.direction = "right" 
	    elif (self.direction == "right"):
	        self.x -=2
	        self.direction = "left"


	if (self.direction == "left"):
	        self.x -=1 
	elif (self.direction == "right"):
	        self.x +=1

    def collide(self, room, player):
	if (player.x > self.x+room.relativex  and 
	player.x < self.x+room.relativex+self.w and 
	player.y > self.y+room.relativey and 
	player.y < self.y+room.relativey + self.h):
	    print "collision with Dark Knight!"
	    if player.hit():
		return 1 
	    else:
	    	return 2 
	else:
	    return 0

		 

# Copyright (C) Johan Ceuppens 2010
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


import pygame
from pygame.locals import *
from stateimagelibrary import *
from playerbase import *

class PlayerAbeilleFighter(PlayerBase):
    "player Fighter"
    def __init__(self,heartmeter):
        PlayerBase.__init__(self,heartmeter)

        self.stimlib = Stateimagelibrary()	
        image = pygame.image.load('./pics/playerabeillefighter1-48x48.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlib.addpicture(image)	
        image = pygame.image.load('./pics/playerabeillefighter2-48x48.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlib.addpicture(image)	
        image = pygame.image.load('./pics/playerabeillefighter3-48x48.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlib.addpicture(image)	
        image = pygame.image.load('./pics/playerabeillefighter2-48x48.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlib.addpicture(image)	
        image = pygame.image.load('./pics/playerabeillefighter1-48x48.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlib.addpicture(image)	
        image = pygame.image.load('./pics/playerabeillefighter2-48x48.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlib.addpicture(image)	
        image = pygame.image.load('./pics/playerabeillefighter3-48x48.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlib.addpicture(image)	

        self.stimlibfight = Stateimagelibrary()	
        image = pygame.image.load('./pics/playerabeillefighterfight1-48x48.bmp').convert()
        image.set_colorkey((0,0,255))
        self.stimlibfight.addpicture(image)
        image = pygame.image.load('./pics/playerabeillefighterfight1-48x48.bmp').convert()
        image.set_colorkey((0,0,255))
        self.stimlibfight.addpicture(image)
        image = pygame.image.load('./pics/playerabeillefighterfight2-48x48.bmp').convert()
        image.set_colorkey((0,0,255))
        self.stimlibfight.addpicture(image)
        image = pygame.image.load('./pics/playerabeillefighterfight2-48x48.bmp').convert()
        image.set_colorkey((0,0,255))
        self.stimlibfight.addpicture(image)
        image = pygame.image.load('./pics/playerabeillefighterfight3-48x48.bmp').convert()
        image.set_colorkey((0,0,255))
        self.stimlibfight.addpicture(image)
        image = pygame.image.load('./pics/playerabeillefighterfight3-48x48.bmp').convert()
        image.set_colorkey((0,0,255))
        self.stimlibfight.addpicture(image)

    def draw(self, screen):
        # NOTE
        if self.fightcounter > 0:
            self.fightcounter += 1
            if self.fightcounter > 10:
                self.fightcounter = 0
            self.stimlibfight.draw(screen,self.x,self.y)
            return
        self.stimlib.draw(screen, self.x,self.y)

    def drawstatic(self,screen):
        self.draw(screen)
        
    def askclass(self):
        return "Fighter"

    def askrace(self):
        return "Abeille"

    def askpicture(self):
        return './pics/taskbar-PC-abeillefighter.bmp'

# Copyright (C) Johan Ceuppens 2010
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


import pygame
from pygame.locals import *
from stateimagelibrary import *
##from playerkatta import *
from playerfighter import *
from playermagicuser import *
from playerpriest import *
from playerpaladin import *
##from playermagicuser import *
##from playerelf import *
##from playerdrow import *
from playerfairy import *
from playerelf import *
from playercentaur import *	
from playergnome import *

class PlayerBase:
    def __init__(self):
        1

class PlayerBase(PlayerBase,PlayerBase):
    "Player"

    PlayerBase.FIGHTER,PlayerBase.MAGICUSER,PlayerBase.PRIEST,PlayerBase.PALADIN = xrange(4)#,PlayerBase.MAGICUSER,PlayerBase.THIEF = xrange(3)
    #PlayerBase.HUMAN,PlayerBase.KATTA,PlayerBase.ELF,PlayerBase.DROW = xrange(4)#,PlayerBase.HUMAN,PlayerBase.DROW = xrange(3)
    PlayerBase.ELF,PlayerBase.CENTAUR,PlayerBase.FAIRY,PlayerBase.GNOME = xrange(4)#,PlayerBase.HUMAN,PlayerBase.DROW = xrange(3)
    
    def __init__(self,PLAYERRACE,PLAYERCLASS,heartmeter):
        classByType = {
                PlayerBase.ELF : PlayerElf,
                PlayerBase.CENTAUR : PlayerCentaur,
                PlayerBase.FAIRY : PlayerFairy,
                PlayerBase.GNOME : PlayerGnome,
        }
        classByType2 = {
                PlayerBase.FIGHTER : PlayerFighter,
                PlayerBase.MAGICUSER : PlayerMagicUser,
                PlayerBase.PRIEST : PlayerPriest,
                PlayerBase.PALADIN : PlayerPaladin,
        }
	self.heartmeter = heartmeter

        self.x = 320 
        self.y = 200 
        self.w = 48 
        self.h = 48
		
        self.highlightbase = 0
        
        self.fightcounter = 0

        self.race = classByType[PLAYERRACE]()
        self.klass = classByType2[PLAYERCLASS]()
        self.inventoryrow1 = []
        self.inventoryrow2 = []
        if self.race.inventoryrow1:
            for o in self.race.inventoryrow1:
                self.inventoryrow1.append(o)
        if self.race.inventoryrow2:
            for o in self.race.inventoryrow2:
                self.inventoryrow2.append(o)
        if self.klass.inventoryrow1:
            for o in self.klass.inventoryrow1:
                self.inventoryrow1.append(o)
        if self.klass.inventoryrow2:
            for o in self.klass.inventoryrow2:
                self.inventoryrow2.append(o)

        self.highlightimage = pygame.image.load('./pics/highlightbase1.bmp').convert()
        self.highlightimage.set_colorkey((0,0,0))

        # clicked mouse button released for moving
        self.mousex = self.x
        self.mousey = self.y
        
    def drawstatic(self, screen):
        # NOTE
        if self.highlightbase:            
            #screen.blit(self.highlightimage, (self.x+room.relativex,self.y+room.relativey))
            screen.blit(self.highlightimage, (self.x-5,self.y+2*self.h/3))

        if self.fightcounter > 0:
            self.fightcounter += 1
            if self.fightcounter > 10:
                self.fightcounter = 0
            self.stimlibfight.draw(screen,self.x,self.y)
            return
	self.stimlib.drawstatic(screen,self.x,self.y,0)
	
    def draw(self, screen):
        # NOTE
        
        if self.highlightbase:            
            screen.blit(self.highlightimage, (self.x-5,self.y*2/3))

        if self.fightcounter > 0:
            self.fightcounter += 1
            if self.fightcounter > 10:
                self.fightcounter = 0
            self.stimlibfight.draw(screen,self.x,self.y)
            return
        self.stimlib.draw(screen, self.x,self.y)

    def fight(self,room):
        self.fightcounter = 1
##        self.x -= 30
##        self.y -= 30
##        self.w += 30
##        self.h += 30
        
        o = room.collidesword(room,self)
        
        if o:
            print 'hit!'
            room.hitwithsword(o)
##        self.x += 30
##        self.y += 30
##        self.w -= 30
##        self.h -= 30
##        
    def hit(self):
	self.heartmeter.index -= 1 
	if self.heartmeter.index <= 0:
		return 0 #FIXME1 FIX for gameover when collision with enemies 
	else:
		return 0	

    def highlight(self):
        self.highlightbase = 1

    def unhighlight(self):
        self.highlightbase = 0

    #FIXME URGENT
    def circumvent(self,room):
         if room.direction == "north":
             if self.mousex <= player.x-room.relativex:
                 room.direction = "west"
             elif self.mousex > player.x-room.relativex:
                 room.direction = "east"


# Copyright (C) Johan Ceuppens 2010
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

import pygame
from pygame.locals import *
from stateimagelibrary import *
from player import *

from inventorylongbow import *

class PlayerCentaurFighter(Player):
    "Player Fighter"
    def __init__(self,heartmeter):
        Player.__init__(self,PlayerBase.CENTAUR,PlayerBase.FIGHTER,heartmeter)
        #self.inventoryrow1 = []
        self.inventoryrow2 = [] # NOTE: sets/removes default sword of PlayerFighter klass
        self.inventoryrow2.append(InventoryLongbow())
        
    def askclass(self):
        return "Fighter"

    def askrace(self):
        return "Centaur"

    def askpicture(self):
        return './pics/taskbar-PC-centaur.bmp'

# Copyright (C) Johan Ceuppens 2010
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

import pygame
from pygame.locals import *
from stateimagelibrary import *
from player import *

class PlayerCentaurMagicUser(Player):
    "Player Fighter"
    def __init__(self,heartmeter):
        Player.__init__(self,PlayerBase.CENTAUR,PlayerBase.MAGICUSER,heartmeter)

    def askclass(self):
        return "Magic User"

    def askrace(self):
        return "Centaur"

    def askpicture(self):
        return './pics/taskbar-PC-centaur.bmp'

# Copyright (C) Johan Ceuppens 2010
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

import pygame
from pygame.locals import *
from stateimagelibrary import *
from player import *
from inventoryspear import *

class PlayerCentaurPaladin(Player):
    "Player Centaur Paladin"
    def __init__(self,heartmeter):
        Player.__init__(self,PlayerBase.CENTAUR,PlayerBase.PALADIN,heartmeter)
        self.inventoryrow2 = [] # NOTE: sets/removes default sword of PlayerFighter klass
        self.inventoryrow2.append(InventorySpear())
        
    def askclass(self):
        return "Paladin"

    def askrace(self):
        return "Centaur"

    def askpicture(self):
        return './pics/taskbar-PC-centaur.bmp'

# Copyright (C) Johan Ceuppens 2010
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

import pygame
from pygame.locals import *
from stateimagelibrary import *
from player import *

class PlayerCentaurPriest(Player):
    "Player Fighter"
    def __init__(self,heartmeter):
        Player.__init__(self,PlayerBase.CENTAUR,PlayerBase.PRIEST,heartmeter)

    def askclass(self):
        return "Priest"

    def askrace(self):
        return "Centaur"

    def askpicture(self):
        return './pics/taskbar-PC-centaur.bmp'

# Copyright (C) Johan Ceuppens 2010
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


import pygame
from pygame.locals import *
from stateimagelibrary import *
class Player:
    def __init__(self):
        1
        
class PlayerCentaur(Player):
    "Player Centaur"
    def __init__(self):
        self.inventoryrow1 = []
        self.inventoryrow2 = []

# Copyright (C) Johan Ceuppens 2010
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


import pygame
from pygame.locals import *
from stateimagelibrary import *
from playerbase import *
from rng import *
from broadsword import *
from rubysword import *

class PlayerDrowMage(PlayerBase):
    "Player Drow"
    def __init__(self,heartmeter):
        PlayerBase.__init__(self,PlayerBase.DROW,PlayerBase.MAGICUSER,heartmeter)
        
        self.stimlib = Stateimagelibrary()	
        image = pygame.image.load('./pics/player1-48x48.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlib.addpicture(image)		

        self.stimlibfight = Stateimagelibrary()	
        image = pygame.image.load('./pics/playerfight1-48x48.bmp').convert()
        image.set_colorkey((0,0,0))
        self.stimlibfight.addpicture(image)	

        self.hitpoints = 50
       	self.sword = BroadSword(0,0)
 
    def askclass(self):
        return "Rogue/Priest"

    def askrace(self):
        return "Elf"

    def askpicture(self):
        return './pics/taskbar-PC-drowmage.bmp'

    def collidewithenemyweapon(self,room,o):
        if o.collide(room,self):
		return self ## NOTE : returns collided entity (single)
		
	return None

    def hitwithenemyweapon(self,damage):
	if damage > 0:
		print 'player is hit!'
        self.hitpoints -= damage

    def pickup(self,room):
        n = room.pickup(self)
	return n

    def fight(self,room):
        self.fightcounter = 1
        o = room.collidesword(self)
        if o:
            o.hitwithweapon(self.sword.roll())
       
    def setrubysword(self):
	self.sword = RubySword(0,0)

# Copyright (C) Johan Ceuppens 2010
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


import pygame
from pygame.locals import *
from stateimagelibrary import *
#from playerbase import *

class PlayerDrow:
    "Player Fighter"
    def __init__(self,heartmeter):
        1#PlayerBase.__init__(self,heartmeter)


# Copyright (C) Johan Ceuppens 2010
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

import pygame
from pygame.locals import *
from stateimagelibrary import *
from player import *
from inventorylongsword import *

class PlayerElfFighter(Player):
    "Player Fighter"
    def __init__(self,heartmeter):
        Player.__init__(self,PlayerBase.ELF,PlayerBase.FIGHTER,heartmeter)
        self.inventoryrow1 = []
        self.inventoryrow2 = []
        self.inventoryrow2.append(InventoryLongsword())
        
    def askclass(self):
        return "Fighter"

    def askrace(self):
        return "Elf"

    def askpicture(self):
        return './pics/taskbar-PC-elffighter.bmp'

# Copyright (C) Johan Ceuppens 2010
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

import pygame
from pygame.locals import *
from stateimagelibrary import *
from player import *

class PlayerElfMagicUser(Player):
    "Player Fighter"
    def __init__(self,heartmeter):
        Player.__init__(self,PlayerBase.ELF,PlayerBase.MAGICUSER,heartmeter)

    def askclass(self):
        return "Magic User"

    def askrace(self):
        return "Elf"

    def askpicture(self):
        return './pics/taskbar-PC-elffighter.bmp'

# Copyright (C) Johan Ceuppens 2010
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

import pygame
from pygame.locals import *
from stateimagelibrary import *
from player import *
from inventorylongsword import *

class PlayerElfPaladin(Player):
    "Player Fighter"
    def __init__(self,heartmeter):
        Player.__init__(self,PlayerBase.ELF,PlayerBase.PALADIN,heartmeter)
        self.inventoryrow1 = []
        self.inventoryrow2 = []
        self.inventoryrow2.append(InventoryLongsword())
        
    def askclass(self):
        return "Paladin"

    def askrace(self):
        return "Elf"

    def askpicture(self):
        return './pics/taskbar-PC-elffighter.bmp'

# Copyright (C) Johan Ceuppens 2010
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

import pygame
from pygame.locals import *
from stateimagelibrary import *
from player import *

class PlayerElfPriest(Player):
    "Player Fighter"
    def __init__(self,heartmeter):
        Player.__init__(self,PlayerBase.ELF,PlayerBase.PRIEST,heartmeter)

    def askclass(self):
        return "Priest"

    def askrace(self):
        return "Elf"

    def askpicture(self):
        return './pics/taskbar-PC-elffighter.bmp'

# Copyright (C) Johan Ceuppens 2010
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


import pygame
from pygame.locals import *
from stateimagelibrary import *
class Player:
    def __init__(self):
        1
        
class PlayerElf(Player):
    "Player Elf"
    def __init__(self):
        self.inventoryrow1 = []
        self.inventoryrow2 = []


# Copyright (C) Johan Ceuppens 2010
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


import pygame
from pygame.locals import *
from stateimagelibrary import *
from playerbase import *

class PlayerElfThief(PlayerBase):
    "Player Thief"
    def __init__(self,heartmeter):
        PlayerBase.__init__(self,heartmeter)

        self.stimlib = Stateimagelibrary()	
        image = pygame.image.load('./pics/playerelfthief1-48x48.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlib.addpicture(image)	
        image = pygame.image.load('./pics/playerelfthief2-48x48.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlib.addpicture(image)	
        image = pygame.image.load('./pics/playerelfthief3-48x48.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlib.addpicture(image)	
        image = pygame.image.load('./pics/playerelfthief2-48x48.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlib.addpicture(image)	
        image = pygame.image.load('./pics/playerelfthief1-48x48.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlib.addpicture(image)	
        image = pygame.image.load('./pics/playerelfthief2-48x48.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlib.addpicture(image)	
        image = pygame.image.load('./pics/playerelfthief3-48x48.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlib.addpicture(image)	

        self.stimlibfight = Stateimagelibrary()	
        image = pygame.image.load('./pics/playerelfthieffight1-48x48.bmp').convert()
        image.set_colorkey((0,0,0))
        self.stimlibfight.addpicture(image)
        image = pygame.image.load('./pics/playerelfthieffight1-48x48.bmp').convert()
        image.set_colorkey((0,0,0))
        self.stimlibfight.addpicture(image)
        image = pygame.image.load('./pics/playerelfthieffight2-48x48.bmp').convert()
        image.set_colorkey((0,0,0))
        self.stimlibfight.addpicture(image)
        image = pygame.image.load('./pics/playerelfthieffight2-48x48.bmp').convert()
        image.set_colorkey((0,0,0))
        self.stimlibfight.addpicture(image)
        image = pygame.image.load('./pics/playerelfthieffight3-48x48.bmp').convert()
        image.set_colorkey((0,0,0))
        self.stimlibfight.addpicture(image)
        image = pygame.image.load('./pics/playerelfthieffight3-48x48.bmp').convert()
        image.set_colorkey((0,0,0))
        self.stimlibfight.addpicture(image)


    def askclass(self):
        return "Thief"

    def askrace(self):
        return "Elven"

    def askpicture(self):
        return './pics/taskbar-PC-elfthief.bmp'

# Copyright (C) Johan Ceuppens 2010
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

import pygame
from pygame.locals import *
from stateimagelibrary import *
from player import *

class PlayerFairyFighter(Player):
    "Player Fighter"
    def __init__(self,heartmeter):
        Player.__init__(self,PlayerBase.FAIRY,PlayerBase.FIGHTER,heartmeter)

    def askclass(self):
        return "Fighter"

    def askrace(self):
        return "Fairy"

    def askpicture(self):
        return './pics/taskbar-PC-fairy.bmp'

# Copyright (C) Johan Ceuppens 2010
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

import pygame
from pygame.locals import *
from stateimagelibrary import *
from player import *
from inventorywand import *

class PlayerFairyMagicUser(Player):
    "Player Fighter"
    def __init__(self,heartmeter):
        Player.__init__(self,PlayerBase.FAIRY,PlayerBase.MAGICUSER,heartmeter)
        #self.inventoryrow1 = []
        self.inventoryrow2 = []
        self.inventoryrow2.append(InventoryWand())
        
    def askclass(self):
        return "Magic User"

    def askrace(self):
        return "Fairy"

    def askpicture(self):
        return './pics/taskbar-PC-fairy.bmp'

# Copyright (C) Johan Ceuppens 2010
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

import pygame
from pygame.locals import *
from stateimagelibrary import *
from player import *

class PlayerFairyPaladin(Player):
    "Player Fighter"
    def __init__(self,heartmeter):
        Player.__init__(self,PlayerBase.FAIRY,PlayerBase.PALADIN,heartmeter)

    def askclass(self):
        return "Paladin"

    def askrace(self):
        return "Fairy"

    def askpicture(self):
        return './pics/taskbar-PC-fairy.bmp'

# Copyright (C) Johan Ceuppens 2010
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

import pygame
from pygame.locals import *
from stateimagelibrary import *
from player import *

class PlayerFairyPriest(Player):
    "Player Fighter"
    def __init__(self,heartmeter):
        Player.__init__(self,PlayerBase.FAIRY,PlayerBase.PRIEST,heartmeter)

    def askclass(self):
        return "Priest"

    def askrace(self):
        return "Fairy"

    def askpicture(self):
        return './pics/taskbar-PC-fairy.bmp'

# Copyright (C) Johan Ceuppens 2010
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


import pygame
from pygame.locals import *

from stateimagelibrary import *
from inventoryfairytunic import *

class Player:
    def __init__(self):
        1
        
class PlayerFairy(Player):
    "Player Elf"
    def __init__(self):
        self.inventoryrow1 = []
        self.inventoryrow2 = []
        #FIXME self.inventoryrow2.append(InventoryFairyTunic())
        


# Copyright (C) Johan Ceuppens 2010
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


import pygame
from pygame.locals import *
from stateimagelibrary import *
from inventorydefaultsword import *

class PlayerFighter:
    "Player Fighter"
    def __init__(self):
        self.inventoryrow1 = []
        self.inventoryrow2 = []
        self.inventoryrow2.append(Inventorydefaultsword())


# Copyright (C) Johan Ceuppens 2010
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


import pygame
from pygame.locals import *
from stateimagelibrary import *
from playerbase import *

class PlayerGnollFighter(PlayerBase):
    "Player Fighter"
    def __init__(self,heartmeter):
        PlayerBase.__init__(self,heartmeter)

        self.stimlib = Stateimagelibrary()	
        image = pygame.image.load('./pics/playergnollfighter1-48x48.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlib.addpicture(image)	
        image = pygame.image.load('./pics/playergnollfighter2-48x48.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlib.addpicture(image)	
        image = pygame.image.load('./pics/playergnollfighter3-48x48.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlib.addpicture(image)	
        image = pygame.image.load('./pics/playergnollfighter2-48x48.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlib.addpicture(image)	
        image = pygame.image.load('./pics/playergnollfighter1-48x48.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlib.addpicture(image)	
        image = pygame.image.load('./pics/playergnollfighter2-48x48.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlib.addpicture(image)	
        image = pygame.image.load('./pics/playergnollfighter3-48x48.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlib.addpicture(image)	

        self.stimlibfight = Stateimagelibrary()	
        image = pygame.image.load('./pics/playergnollfighterfight1-48x48.bmp').convert()
        image.set_colorkey((0,0,0))
        self.stimlibfight.addpicture(image)
        image = pygame.image.load('./pics/playergnollfighterfight1-48x48.bmp').convert()
        image.set_colorkey((0,0,0))
        self.stimlibfight.addpicture(image)
        image = pygame.image.load('./pics/playergnollfighterfight2-48x48.bmp').convert()
        image.set_colorkey((0,0,0))
        self.stimlibfight.addpicture(image)
        image = pygame.image.load('./pics/playergnollfighterfight2-48x48.bmp').convert()
        image.set_colorkey((0,0,0))
        self.stimlibfight.addpicture(image)
        image = pygame.image.load('./pics/playergnollfighterfight3-48x48.bmp').convert()
        image.set_colorkey((0,0,0))
        self.stimlibfight.addpicture(image)
        image = pygame.image.load('./pics/playergnollfighterfight3-48x48.bmp').convert()
        image.set_colorkey((0,0,0))
        self.stimlibfight.addpicture(image)

    def askclass(self):
        return "Fighter"

    def askrace(self):
        return "Bugbear"

    def askpicture(self):
        return './pics/taskbar-PC-gnoll.bmp'

# Copyright (C) Johan Ceuppens 2010
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

import pygame
from pygame.locals import *
from stateimagelibrary import *
from player import *

class PlayerGnomeFighter(Player):
    "Player Fighter"
    def __init__(self,heartmeter):
        Player.__init__(self,PlayerBase.GNOME,PlayerBase.FIGHTER,heartmeter)

    def askclass(self):
        return "Fighter"

    def askrace(self):
        return "Gnome"

    def askpicture(self):
        return './pics/taskbar-PC-gnome.bmp'

# Copyright (C) Johan Ceuppens 2010
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

import pygame
from pygame.locals import *
from stateimagelibrary import *
from player import *
from inventorywandred import *

class PlayerGnomeMagicUser(Player):
    "Player Fighter"
    def __init__(self,heartmeter):
        Player.__init__(self,PlayerBase.GNOME,PlayerBase.MAGICUSER,heartmeter)
        #self.inventoryrow1 = []
        self.inventoryrow2 = []
        self.inventoryrow2.append(InventoryWandRed())
        
    def askclass(self):
        return "Magic User"

    def askrace(self):
        return "Gnome"

    def askpicture(self):
        return './pics/taskbar-PC-gnome.bmp'

# Copyright (C) Johan Ceuppens 2010
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

import pygame
from pygame.locals import *
from stateimagelibrary import *
from player import *

class PlayerGnomePaladin(Player):
    "Player Fighter"
    def __init__(self,heartmeter):
        Player.__init__(self,PlayerBase.GNOME,PlayerBase.PALADIN,heartmeter)

    def askclass(self):
        return "Paladin"

    def askrace(self):
        return "Gnome"

    def askpicture(self):
        return './pics/taskbar-PC-gnome.bmp'

# Copyright (C) Johan Ceuppens 2010
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

import pygame
from pygame.locals import *
from stateimagelibrary import *
from player import *

class PlayerGnomePriest(Player):
    "Player Fighter"
    def __init__(self,heartmeter):
        Player.__init__(self,PlayerBase.GNOME,PlayerBase.PRIEST,heartmeter)

    def askclass(self):
        return "Priest"

    def askrace(self):
        return "Gnome"

    def askpicture(self):
        return './pics/taskbar-PC-gnome.bmp'

# Copyright (C) Johan Ceuppens 2010
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


import pygame
from pygame.locals import *
from stateimagelibrary import *
class Player:
    def __init__(self):
        1
        
class PlayerGnome(Player):
    "Player Elf"
    def __init__(self):
        self.inventoryrow1 = []
        self.inventoryrow2 = []


# Copyright (C) Johan Ceuppens 2010
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


import pygame
from pygame.locals import *
from stateimagelibrary import *
from player import *

class PlayerHumanFighter(Player):
    "Player Fighter"
    def __init__(self,heartmeter):
        Player.__init__(self,PlayerBase.HUMAN,PlayerBase.FIGHTER,heartmeter)

    def askclass(self):
        return "Fighter"

    def askrace(self):
        return "Human"

    def askpicture(self):
        return './pics/taskbar-PC.bmp'

# Copyright (C) Johan Ceuppens 2010
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


import pygame
from pygame.locals import *
from stateimagelibrary import *

class Player:
    def __init__(self):
        1

class PlayerHuman(Player):
    "Player Human"
    def __init__(self):
        1#Player.__init__(self,PlayerBase.HUMAN,PlayerBase.FIGHTER)


# Copyright (C) Johan Ceuppens 2010
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


import pygame
from pygame.locals import *
from stateimagelibrary import *
from playerbase import *
from rng import *
from broadsword import *
from rubysword import *

class PlayerKattaFighter(PlayerBase):
    "Player Katta Fighter"
    def __init__(self,heartmeter):
        PlayerBase.__init__(self,PlayerBase.KATTA,PlayerBase.FIGHTER,heartmeter)
        
        self.stimlib = Stateimagelibrary()	
        image = pygame.image.load('./pics/playerkattafighter1-48x48.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlib.addpicture(image)	
        image = pygame.image.load('./pics/playerkattafighter2-48x48.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlib.addpicture(image)	
        image = pygame.image.load('./pics/playerkattafighter3-48x48.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlib.addpicture(image)	
        image = pygame.image.load('./pics/playerkattafighter2-48x48.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlib.addpicture(image)	
        image = pygame.image.load('./pics/playerkattafighter1-48x48.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlib.addpicture(image)	
        image = pygame.image.load('./pics/playerkattafighter2-48x48.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlib.addpicture(image)	
        image = pygame.image.load('./pics/playerkattafighter3-48x48.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlib.addpicture(image)	

        self.stimlibfight = Stateimagelibrary()	
        image = pygame.image.load('./pics/playerkattafighterfight1-48x48.bmp').convert()
        image.set_colorkey((0,0,0))
        self.stimlibfight.addpicture(image)
        image = pygame.image.load('./pics/playerkattafighterfight1-48x48.bmp').convert()
        image.set_colorkey((0,0,0))
        self.stimlibfight.addpicture(image)
        image = pygame.image.load('./pics/playerkattafighterfight2-48x48.bmp').convert()
        image.set_colorkey((0,0,0))
        self.stimlibfight.addpicture(image)
        image = pygame.image.load('./pics/playerkattafighterfight2-48x48.bmp').convert()
        image.set_colorkey((0,0,0))
        self.stimlibfight.addpicture(image)
        image = pygame.image.load('./pics/playerkattafighterfight3-48x48.bmp').convert()
        image.set_colorkey((0,0,0))
        self.stimlibfight.addpicture(image)
        image = pygame.image.load('./pics/playerkattafighterfight3-48x48.bmp').convert()
        image.set_colorkey((0,0,0))
        self.stimlibfight.addpicture(image)

        self.hitpoints = 50
       	self.sword = BroadSword(0,0)
 
    def askclass(self):
        return "Fighter"

    def askrace(self):
        return "Katta"

    def askpicture(self):
        return './pics/taskbar-PC-kattafighter.bmp'

    def collidewithenemyweapon(self,room,o):
        if o.collide(room,self):
		return self ## NOTE : returns collided entity (single)
		
	return None

    def hitwithenemyweapon(self,damage):
	if damage > 0:
		print 'player is hit!'
        self.hitpoints -= damage

    def pickup(self,room):
        n = room.pickup(self)
	return n

    def fight(self,room):
        self.fightcounter = 1
        o = room.collidesword(self)
        if o:
            o.hitwithweapon(self.sword.roll())
       
    def setrubysword(self):
	self.sword = RubySword(0,0)

# Copyright (C) Johan Ceuppens 2010
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


import pygame
from pygame.locals import *
from stateimagelibrary import *
#from playerbase import *

class PlayerKatta:
    "Player Fighter"
    def __init__(self,heartmeter):
        1#PlayerBase.__init__(self,heartmeter)


# Copyright (C) Johan Ceuppens 2010
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


import pygame
from pygame.locals import *
from stateimagelibrary import *
#from playerbase import *

class PlayerMagicUser:#(PlayerBase):
    "Player Magic User"
    def __init__(self):
        self.inventoryrow1 = []
        self.inventoryrow2 = []

# Copyright (C) Johan Ceuppens 2010 
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


import pygame
from pygame.locals import *
from gameobject import *

class Selector:
    def __init__(self,screen):
        self.blankimage = pygame.image.load('./pics/blank.bmp').convert()
        self.font = pygame.font.SysFont("Vera", 48)
        self.font2 = pygame.font.SysFont("Vera", 28)
        
class RaceSelector(Selector):
    def __init__(self,screen):
        Selector.__init__(self, screen)
        class SelectorImg:
            def __init__(self,x,y,text,imgfn):
                self.x = x
                self.y = y
                self.text = text               
                self.image = Selector(screen).font.render(text,6,(0,0,200))
                self.image2 = Selector(screen).font.render(text,6,(0,200,0))
                self.img = pygame.image.load(imgfn)
                self.img.set_colorkey((0,0,0)) 
    
            def draw(self,double = 0):
                screen.blit(Selector(None).font2.render('Race ?', 6, (0,0,200)), (10,20))
                screen.blit(self.image, (self.x,self.y))
                screen.blit(self.image2, (self.x+2,self.y+2))
                screen.blit(self.img, (self.x+200,self.y))
                
        SelectorImg(100,100,"Elf","./pics/player1-48x48.bmp").draw()
        SelectorImg(100,200,"Centaur","./pics/centaur1-64x64.bmp").draw()
        SelectorImg(100,300,"Fairy","./pics/fairy1-48x48.bmp").draw()
        SelectorImg(100,400,"Gnome","./pics/gnome1-48x48.bmp").draw()
        
        def domouse(self):
            mousepos = pygame.mouse.get_pos()
            mousex = mousepos[0]
            mousey = mousepos[1]


class ClassSelector(Selector):
    def __init__(self,screen):
        Selector.__init__(self, screen)
        class SelectorImg:
            def __init__(self,x,y,text,imgfn):
                self.x = x
                self.y = y
                self.text = text               
                self.image = Selector(screen).font.render(text,6,(0,0,200))
                self.image2 = Selector(screen).font.render(text,6,(0,200,0))
                #self.img = pygame.image.load(imgfn)
                #self.img.set_colorkey((0,0,0)) 
    
            def draw(self,double = 0):
                
                screen.blit(Selector(None).font2.render('Class ?', 6, (0,0,200)), (10,20))
                screen.blit(self.image, (self.x,self.y))
                screen.blit(self.image2, (self.x+2,self.y+2))
                #screen.blit(self.img, (self.x+200,self.y))
                
        SelectorImg(100,100,"Fighter","./pics/player1-48x48.bmp").draw()
        SelectorImg(100,200,"Magic User","./pics/fairy1-48x48.bmp").draw()
        SelectorImg(100,300,"Priest","./pics/centaur1-64x64.bmp").draw()
        SelectorImg(100,400,"Paladin","./pics/fairy1-48x48.bmp").draw()
        
        def domouse(self):
            mousepos = pygame.mouse.get_pos()
            mousex = mousepos[0]
            mousey = mousepos[1]

class DietySelector(Selector):
    def __init__(self,screen):
        Selector.__init__(self, screen)
        class SelectorImg:
            def __init__(self,x,y,text,imgfn):
                self.x = x
                self.y = y
                self.text = text               
                self.image = Selector(screen).font.render(text,6,(0,0,200))
                self.image2 = Selector(screen).font.render(text,6,(0,200,0))
                #self.img = pygame.image.load(imgfn)
                #self.img.set_colorkey((0,0,0)) 
    
            def draw(self,double = 0):
                
                screen.blit(Selector(None).font2.render('Diety ?', 6, (0,0,200)), (10,20))
                screen.blit(self.image, (self.x,self.y))
                screen.blit(self.image2, (self.x+2,self.y+2))
                #screen.blit(self.img, (self.x+200,self.y))
                
        SelectorImg(100,100,"Skerrit","./pics/player1-48x48.bmp").draw()
        SelectorImg(100,200,"Ehlonna","./pics/fairy1-48x48.bmp").draw()
        SelectorImg(100,300,"Goldenroost","./pics/centaur1-64x64.bmp").draw()
        
        def domouse(self):
            mousepos = pygame.mouse.get_pos()
            mousex = mousepos[0]
            mousey = mousepos[1]

class AnotherPCSelector(Selector):
    def __init__(self,screen):
        Selector.__init__(self, screen)
        class SelectorImg:
            def __init__(self,x,y,text,imgfn):
                self.x = x
                self.y = y
                self.text = text               
                self.image = Selector(screen).font.render(text,6,(0,0,200))
                self.image2 = Selector(screen).font.render(text,6,(0,200,0))
                #self.img = pygame.image.load(imgfn)
                #self.img.set_colorkey((0,0,0)) 
    
            def draw(self,double = 0):
                
                screen.blit(Selector(None).font2.render('Create an extra character ?', 6, (0,0,200)), (10,20))
                screen.blit(self.image, (self.x,self.y))
                screen.blit(self.image2, (self.x+2,self.y+2))
                #screen.blit(self.img, (self.x+200,self.y))
                
        SelectorImg(100,100,"Yes","./pics/player1-48x48.bmp").draw()
        SelectorImg(100,200,"No","./pics/fairy1-48x48.bmp").draw()
        
        def domouse(self):
            mousepos = pygame.mouse.get_pos()
            mousex = mousepos[0]
            mousey = mousepos[1]
        
class PlayerMaker:
    "Class and Race"
    def __init__(self):
        self.background = pygame.image.load('./pics/blank.bmp').convert()
        self.klass = ""
        self.race = ""
  
    def draw(self):
        1

    def start(self,screen):
        self.blankimage = pygame.image.load('./pics/blank.bmp').convert()
        screen.blit(self.blankimage, (0,0))
        flag = 1
        while flag:
                self.draw()
                rs = RaceSelector(screen)
                pygame.display.update()
                for event in pygame.event.get():
                    if event.type == QUIT:
                        break
                    if event.type == pygame.MOUSEBUTTONDOWN:
                        position = pygame.mouse.get_pos()
                        mousex = position[0]
                        mousey = position[1]
                        
                        if mousex > 100 and mousex < 200 and mousey > 100 and mousey < 200:
                            self.race = "Elf"    
                            self.klass = "Fighter"
                            flag = 0
                        elif mousex > 100 and mousex < 200 and mousey > 200 and mousey < 300:
                            self.race = "Centaur"    
                            self.klass = "Fighter"
                            flag = 0
                        elif mousex > 100 and mousex < 200 and mousey > 300 and mousey < 400:
                            self.race = "Fairy"    
                            self.klass = "Fighter"
                            flag = 0

                        elif mousex > 100 and mousex < 200 and mousey > 400 and mousey < 500:
                            self.race = "Gnome"    
                            self.klass = "Fighter"
                            flag = 0
        screen.blit(self.blankimage, (0,0))
        flag = 1
        while flag:
                self.draw()
                rs = ClassSelector(screen)
                pygame.display.update()
                for event in pygame.event.get():
                    if event.type == QUIT:
                        break
                    if event.type == pygame.MOUSEBUTTONDOWN:
                        position = pygame.mouse.get_pos()
                        mousex = position[0]
                        mousey = position[1]
                        
                        if mousex > 100 and mousex < 200 and mousey > 100 and mousey < 200:
                            self.klass = "Fighter"
                            flag = 0
                        elif mousex > 100 and mousex < 200 and mousey > 200 and mousey < 300:
                            self.klass = "Magic User"
                            flag = 0
                        elif mousex > 100 and mousex < 200 and mousey > 300 and mousey < 400:
                            self.klass = "Priest"
                            self.blankimage = pygame.image.load('./pics/blank.bmp').convert()
                            screen.blit(self.blankimage, (0,0)) 
                            while flag:
                                self.draw()
                                rs = DietySelector(screen)
                                pygame.display.update()
                                for event in pygame.event.get():
                                    if event.type == QUIT:
                                        return
                                    if event.type == pygame.MOUSEBUTTONDOWN:
                                        position = pygame.mouse.get_pos()
                                        mousex = position[0]
                                        mousey = position[1]
                                        
                                        if mousex > 100 and mousex < 200 and mousey > 100 and mousey < 200:
                                            self.diety = "Skerrit"
                                            flag = 0
                                        elif mousex > 100 and mousex < 200 and mousey > 200 and mousey < 300:
                                            self.diety = "Ehlonna"
                                            flag = 0
                                        elif mousex > 100 and mousex < 200 and mousey > 300 and mousey < 400:
                                            self.diety = "Goldenroost"
                                            flag = 0
                            
                        elif mousex > 100 and mousex < 200 and mousey > 400 and mousey < 500:
                            self.klass = "Paladin"
                            flag = 0
        flag = 1
        self.blankimage = pygame.image.load('./pics/blank.bmp').convert()
        screen.blit(self.blankimage, (0,0))
        while flag:
            self.draw()
            rs = AnotherPCSelector(screen)
            pygame.display.update()
            for event in pygame.event.get():
                if event.type == QUIT:
                    return
                if event.type == pygame.MOUSEBUTTONDOWN:
                    position = pygame.mouse.get_pos()
                    mousex = position[0]
                    mousey = position[1]
                    
                    if mousex > 100 and mousex < 200 and mousey > 100 and mousey < 200:
                        return 1 
                    elif mousex > 100 and mousex < 200 and mousey > 200 and mousey < 300:
                        return 0

    def askrace(self):
        return self.race

    def askclass(self):
        return self.klass

    def askdiety(self):
        return self.diety

# Copyright (C) Johan Ceuppens 2010
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


import pygame
from pygame.locals import *
from stateimagelibrary import *

class Player:
    "Player"
    def __init__(self,heartmeter):

	self.heartmeter = heartmeter

        self.x = 150 
        self.y = 150 
        self.w = 48 
        self.h = 48
	self.stimlib = Stateimagelibrary()	
        image = pygame.image.load('./pics/player1-30x30.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlib.addpicture(image)	
        image = pygame.image.load('./pics/player2-30x30.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlib.addpicture(image)	
        image = pygame.image.load('./pics/player3-30x30.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlib.addpicture(image)	
        image = pygame.image.load('./pics/player2-30x30.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlib.addpicture(image)	
        image = pygame.image.load('./pics/player1-30x30.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlib.addpicture(image)	
        image = pygame.image.load('./pics/player2-30x30.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlib.addpicture(image)	
        image = pygame.image.load('./pics/player3-30x30.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlib.addpicture(image)	

        self.stimlibfight = Stateimagelibrary()	
        image = pygame.image.load('./pics/playerfight1-30x30.bmp').convert()
        image.set_colorkey((0,0,0))
        self.stimlibfight.addpicture(image)
        image = pygame.image.load('./pics/playerfight1-30x30.bmp').convert()
        image.set_colorkey((0,0,0))
        self.stimlibfight.addpicture(image)
        image = pygame.image.load('./pics/playerfight2-30x30.bmp').convert()
        image.set_colorkey((0,0,0))
        self.stimlibfight.addpicture(image)
        image = pygame.image.load('./pics/playerfight2-30x30.bmp').convert()
        image.set_colorkey((0,0,0))
        self.stimlibfight.addpicture(image)
        image = pygame.image.load('./pics/playerfight3-30x30.bmp').convert()
        image.set_colorkey((0,0,0))
        self.stimlibfight.addpicture(image)
        image = pygame.image.load('./pics/playerfight3-30x30.bmp').convert()
        image.set_colorkey((0,0,0))
        self.stimlibfight.addpicture(image)

        self.fightcounter = 0

    def drawstatic(self, screen):
        # NOTE
        if self.fightcounter > 0:
            self.fightcounter += 1
            if self.fightcounter > 10:
                self.fightcounter = 0
            self.stimlibfight.draw(screen,self.x,self.y)
            return
	self.stimlib.drawstatic(screen,self.x,self.y,0)
	
    def draw(self, screen):
        # NOTE
        if self.fightcounter > 0:
            self.fightcounter += 1
            if self.fightcounter > 10:
                self.fightcounter = 0
            self.stimlibfight.draw(screen,self.x,self.y)
            return
        self.stimlib.draw(screen, self.x,self.y)

    def fight(self,room,player):
        self.fightcounter = 1
        self.x -= 30
        self.y -= 30
        self.w += 30
        self.h += 30
        o = room.collidesword(room,player)
        if o:
            room.hitwithsword(o)
        self.x += 30
        self.y += 30
        self.w -= 30
        self.h -= 30
        
    def hit(self):
	self.heartmeter.index -= 1 
	if self.heartmeter.index <= 0:
		return 0 #FIXME1 FIX for gameover when collision with enemies 
	else:
		return 0	

# Copyright (C) Johan Ceuppens 2010
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


import pygame
from pygame.locals import *
from stateimagelibrary import *
#from playerbase import *

class PlayerPaladin:
    "Player Fighter"
    def __init__(self):
        self.inventoryrow1 = []
        self.inventoryrow2 = []


# Copyright (C) Johan Ceuppens 2010
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


import pygame
from pygame.locals import *
from stateimagelibrary import *
#from playerbase import *

class PlayerPriest:
    "Player Fighter"
    def __init__(self):
        self.inventoryrow1 = []
        self.inventoryrow2 = []


# Copyright (C) Johan Ceuppens 2010
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


import pygame
from pygame.locals import *
from stateimagelibrary import *
from playerbase import *
from rng import *
from broadsword import *
from rubysword import *

class Player(PlayerBase):
    "Player"
    def __init__(self,PLAYERRACE,PLAYERCLASS,heartmeter):
        PlayerBase.__init__(self,PLAYERRACE,PLAYERCLASS,heartmeter)
        
        self.stimlib = Stateimagelibrary()
        if PLAYERRACE == PlayerBase.ELF:
            image = pygame.image.load('./pics/player1-48x48.bmp').convert()
        if PLAYERRACE == PlayerBase.CENTAUR:
            image = pygame.image.load('./pics/centaur1-64x64.bmp').convert()
        if PLAYERRACE == PlayerBase.FAIRY:
            image = pygame.image.load('./pics/fairy1-48x48.bmp').convert()
        if PLAYERRACE == PlayerBase.GNOME:
            if PLAYERCLASS == PlayerBase.MAGICUSER:
                image = pygame.image.load('./pics/gnomemagicuser1-48x48.bmp').convert()
            else:
                image = pygame.image.load('./pics/gnome1-48x48.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlib.addpicture(image)		

        self.stimlibfight = Stateimagelibrary()
        if PLAYERRACE == PlayerBase.ELF:
            image = pygame.image.load('./pics/player1-48x48.bmp').convert()
        if PLAYERRACE == PlayerBase.CENTAUR:
            image = pygame.image.load('./pics/centaur1-64x64.bmp').convert()
        if PLAYERRACE == PlayerBase.FAIRY:
            image = pygame.image.load('./pics/fairy1-48x48.bmp').convert()
        if PLAYERRACE == PlayerBase.GNOME:
            image = pygame.image.load('./pics/gnome1-48x48.bmp').convert()
        ##image = pygame.image.load('./pics/playerfight1-48x48.bmp').convert()
        image.set_colorkey((0,0,0))
        self.stimlibfight.addpicture(image)	

        self.hitpoints = 50
       	self.sword = BroadSword(0,0)
 
    def askclass(self):
        return ""

    def askrace(self):
        return ""

    def askpicture(self):
        return ''

    def collidewithenemyweapon(self,room,o):
        if o.collide(room,self):
		return self ## NOTE : returns collided entity (single)
		
	return None

    def hitwithenemyweapon(self,damage):
	if damage > 0:
		print 'player is hit!'
        self.hitpoints -= damage

    def pickup(self,room):
        n = room.pickup(self)
	return n

    def fight(self,room):
        self.fightcounter = 1
        o = room.collidesword(self)
        if o:
            o.hitwithweapon(self.sword.roll())
       
    def setrubysword(self):
	self.sword = RubySword(0,0)

# Copyright (C) Johan Ceuppens 2010
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


import pygame
from pygame.locals import *
from stateimagelibrary import *
#from playerbase import *

class PlayerThief:
    "Player Fighter"
    def __init__(self,heartmeter):
        1#PlayerBase.__init__(self,heartmeter)


# Copyright (C) Johan Ceuppens 2010 
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


import pygame
from pygame.locals import *
from gameobject import *
from random import *

class RNG(Gameobject):
    "Random Number God"
    def __init__(self):
        1

    def rolld6(self):
        return randint(1,6)

    def rolld4(self):
        return randint(1,4)

    def rolld2(self):
        return randint(1,2)

    def rollbroadsword(self):
        if randint(0,3) > 2:
            return 0
        
        r = self.rolld4()
        if r == 4: # critical hit
            return 4*2
        else:
            return r

    def rollgoblinknife(self):
        if randint(0,3) <= 2:
            return 0
        
        r = self.rolld2()
        return r

    def rollcentaur1(self):
        if randint(0,3) <= 1:
            return 0
        
        r = self.rolld6()
        return r

    def rolllongbow(self):
        if randint(0,3) <= 2:
            return 0
        
        r = self.rolld6()
        return r

    def rollsnakebite(self):
        if randint(0,3) <= 2:
            return 0
        
        r = self.rolld2()
        return r
   
    def rollbeholderbatzap(self):
	if randint(0,4) <= 3:
		return 0

	r = self.rolld2()
	return r
    def rollbeholderzap(self):
	if randint(0,1) == 0:
		return 0

	r = self.rolld4()
	return r

# Copyright (C) Johan Ceuppens 2010
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


import pygame
from pygame.locals import *
from roadsign import *
from stateimagelibrary import *
import random
from time import *

class RoadSignInn(RoadSign):
    ""
    def __init__(self,xx,yy):
	Gameobject.__init__(self, xx, yy)
        self.image = pygame.image.load('./pics/roadsign2-36x36.bmp').convert()
        self.image.set_colorkey((0,0,0)) 
      
    def talk(self, screen,font):
        if self.talkcounter == 0:
            return
        
        if self.talkcounter > 1:
                self.talkcounter = 0
                return 
        talkover = 0
        while talkover == 0:
            pygame.display.update()
            if self.talkcounter == 1:
                screen.blit(font.render("Friendly Arm Inn", 6, (255,255,255)), (10,100))
            for event in pygame.event.get():
                if event.type == QUIT:
                    return
                elif event.type == KEYDOWN:
                    if event.key == K_z:
                        talkover = 1
                        self.talkcounter += 1
                

# Copyright (C) Johan Ceuppens 2010
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


import pygame
from pygame.locals import *
from gameobject import *
from stateimagelibrary import *
import random
from time import *

class RoadSign(Gameobject):
    ""
    def __init__(self,xx,yy):
	Gameobject.__init__(self, xx, yy)
        self.w = 36
        self.h = 36 
        self.image = pygame.image.load('./pics/roadsign1-36x36.bmp').convert()
        self.image.set_colorkey((0,0,0)) 
        self.talkcounter = 0
        
    def draw(self, screen, room):
        screen.blit(self.image, (self.x+room.relativex,self.y+room.relativey))
	    
	     
    def update(self,room):
        1

    def collide(self, room, player):
	if (player.x > self.x+room.relativex  and 
	player.x < self.x+room.relativex+self.w and 
	player.y > self.y+room.relativey and 
	player.y < self.y+room.relativey + self.h):
	    print "collision with RoadSign!"
	    return 2 
	else:
	    return 0
		 
    def talk(self, screen,font):
        if self.talkcounter == 0:
            return
        
        if self.talkcounter > 1:
                self.talkcounter = 0
                return 
        talkover = 0
        while talkover == 0:
            pygame.display.update()
            if self.talkcounter == 1:
                screen.blit(font.render("", 6, (255,255,255)), (10,100))
            for event in pygame.event.get():
                if event.type == QUIT:
                    return
                elif event.type == KEYDOWN:
                    if event.key == K_z:
                        talkover = 1
                        self.talkcounter += 1
                

# Copyright (C) Johan Ceuppens 2010
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


import pygame
from pygame.locals import *
from gameobject import *
from stateimagelibrary import *
import random
from rng import *

class RubySword(Gameobject):
    "Ruby Sword"
    def __init__(self,xx,yy):
	Gameobject.__init__(self, xx, yy)
        self.w = 36
        self.h = 36
	self.stimlib = Stateimagelibrary()		
        image = pygame.image.load('./pics/taskbar-rubysword1-32x32.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlib.addpicture(image)	
	self.hitpoints = 10	

    def draw(self, screen, room):
        self.stimlib.draw(screen, self.x+room.relativex,self.y+room.relativey)
	
	     
    def update(self,room,player):
	1

    def pickup(self, room):
	return 5

    def collide(self, room, player):
        # FIX BUG
        ###print 'gameobject x=%d y=%d player x=%d y=%d' % (self.x,self.y,player.x-room.relativex,player.y-room.relativey)
        #print 'gameobject x=%d y=%d player x=%d y=%d' % (self.x,self.y,player.x-room.relativex,player.y-room.relativey)
	if (player.x-room.relativex > self.x  and 
	player.x-room.relativex < self.x+self.w and 
	player.y-room.relativey > self.y and 
	player.y-room.relativey < self.y + self.h):
	    print "collision with RubySword!"
	    return 5 
	else:
	    return 0 ## for game self.talker

    def collidewithsword(self, room, player):
	return 0

    def roll(self):
	return RNG().rollrubysword()        

# Copyright (C) Johan Ceuppens 2010 
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


import pygame
from pygame.locals import *
from gameobject import *

class Selector:
    "Class and Race Selector"
    def __init__(self, screen, font):
        self.screen = screen
        self.font = font
        self.background = pygame.image.load('./pics/blank.bmp').convert()
        self.klass = "Fighter"
        self.race = "Elf"
        # fighters
        #self.humanfighterimage = pygame.image.load('./pics/taskbar-PC.bmp').convert()
        #self.gnollfighterimage = pygame.image.load('./pics/taskbar-PC-gnoll.bmp').convert()
        #self.kattafighterimage = pygame.image.load('./pics/taskbar-PC-kattafighter.bmp').convert()
        self.elffighterimage = pygame.image.load('./pics/taskbar-PC-elffighter.bmp').convert()
        # magic users
       
        # thieves
         
    def draw(self):
        # fighters
##        self.screen.blit(self.background, (0, 300))       
##        self.screen.blit(self.humanfighterimage, (0,0))
##        self.screen.blit(self.gnollfighterimage, (50,0))
##        self.screen.blit(self.kattafighterimage, (100,0))
        self.screen.blit(self.elffighterimage, (0,0))
         # magic users
        

    def select(self):
        while 1:
                self.draw()
                pygame.display.update()
                for event in pygame.event.get():
                    if event.type == QUIT:
                        return
                    if event.type == pygame.MOUSEBUTTONDOWN:
                        position = pygame.mouse.get_pos()
                        mousex = position[0]
                        mousey = position[1]
                        
                        if mousex > 0 and mousex < 50 and mousey > 0 and mousey < 50:
                            self.race = "Elf"    
                            self.klass = "Fighter"
                            return
                        elif mousex > 50 and mousex < 100 and mousey > 0 and mousey < 50:
                            self.race = "Bugbear"    
                            self.klass = "Fighter"
                            return
                        elif mousex > 100 and mousex < 150 and mousey > 0 and mousey < 50:
                            self.race = "Katta"    
                            self.klass = "Fighter"
                            return
                        elif mousex > 150 and mousex < 200 and mousey > 0 and mousey < 50:
                            self.race = "Elven"    
                            self.klass = "Fighter"
                            return
                        elif mousex > 200 and mousex < 250 and mousey > 0 and mousey < 50:
                            self.race = "Abeille"    
                            self.klass = "Fighter"
                            return

    def askrace(self):
        return self.race

    def askclass(self):
        return self.klass

# Copyright (C) Johan Ceuppens 2010
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


import pygame
from pygame.locals import *
from gameobject import *
from stateimagelibrary import *
import random
from time import *
from math import *

class Snake1(Gameobject):
    "Snake"
    def __init__(self,xx,yy):
	Gameobject.__init__(self, xx, yy)
        self.w = 88
        self.h = 48
        self.PI = 3.14182829
        self.hitpoints = 3
        
		
        self.headimage = pygame.image.load('./pics/snakehead1-48x48.bmp').convert()
        self.headimage.set_colorkey((0,0,0)) 
		
        self.bodyimage = pygame.image.load('./pics/snakebody1-48x48.bmp').convert()
        self.bodyimage.set_colorkey((0,0,0)) 
	
	self.talkcounter = 0
	self.direction = "down"

        self.angle = sqrt(2)/2

    def draw(self, screen, room):
        sleep(.1) # FIX goblin sleep
        self.angle += self.PI/8
        self.x -= 10
        self.y = sin(self.angle)*20
        screen.blit(self.bodyimage, (self.x+room.relativex,self.y+room.relativey))
        self.angle += self.PI/8
        self.y = sin(self.angle)*20
        screen.blit(self.bodyimage, (self.x-10+room.relativex,self.y+room.relativey))
        self.angle += self.PI/8
        self.y = sin(self.angle)*20
        screen.blit(self.bodyimage, (self.x-20+room.relativex,self.y+room.relativey))
        self.angle += self.PI/8
        self.y = sin(self.angle)*20
        screen.blit(self.bodyimage, (self.x-30+room.relativex,self.y+room.relativey))

        self.angle += self.PI/8
        self.x -= 10
        self.y = sin(self.angle)*20
        screen.blit(self.headimage, (self.x-40+room.relativex,self.y+room.relativey))
        self.angle -= self.PI/8
        self.angle -= self.PI/8
        self.angle -= self.PI/8
	     
    def update(self,room,player):
        1

    def collide(self, room, player):
        
	if (player.x > self.x+room.relativex  and 
	player.x < self.x+room.relativex+self.w and 
	player.y > self.y+room.relativey and 
	player.y < self.y+room.relativey + self.h):
	    print "collision with Snake!"
	    return 2 
	else:
	    return 0 ## for game self.talker

    def fight(self,room,player):
        1

# Copyright (C) Johan Ceuppens 2010
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


import pygame
from pygame.locals import *
from gameobject import *
from stateimagelibrary import *
import random
from rng import *
from time import *

class Snake2(Gameobject):
    "Snake static left and right pic"
    def __init__(self,xx,yy):
	Gameobject.__init__(self, xx, yy)
        self.w = 36
        self.h = 36

        self.hitpoints = 2
        
	self.stimlibleft = Stateimagelibrary()	
	self.stimlibright = Stateimagelibrary()	
	self.stimlibdown = Stateimagelibrary()	
	self.stimlibup = Stateimagelibrary()	
        image = pygame.image.load('./pics/snakeleft1-48x48.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibleft.addpicture(image)	
        image = pygame.image.load('./pics/snakeleft1-48x48.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibleft.addpicture(image)
        image = pygame.image.load('./pics/snake1-48x48.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibright.addpicture(image)	
        image = pygame.image.load('./pics/snake1-48x48.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibright.addpicture(image)
        image = pygame.image.load('./pics/snake1-48x48.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibdown.addpicture(image)	
        image = pygame.image.load('./pics/snake1-48x48.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibdown.addpicture(image)
        image = pygame.image.load('./pics/snake1-48x48.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibup.addpicture(image)	
        image = pygame.image.load('./pics/snake1-48x48.bmp').convert()
        image.set_colorkey((0,0,255)) 
	self.stimlibup.addpicture(image)

	self.talkcounter = 0
	self.direction = "left"

    def draw(self, screen, room):
	if (self.direction == "left"):
            self.stimlibleft.draw(screen, self.x+room.relativex,self.y+room.relativey)
	elif (self.direction == "right"):
            self.stimlibright.draw(screen, self.x+room.relativex,self.y+room.relativey)
	elif (self.direction == "down"):
            self.stimlibdown.draw(screen, self.x+room.relativex,self.y+room.relativey)
	elif (self.direction == "up"):
            self.stimlibup.draw(screen, self.x+room.relativex,self.y+room.relativey)
	    
	     
    def update(self,room,player):
        ###sleep(.04) # FIX goblin sleep
	if room.collidewithenemy(self):
	    if (self.direction == "right"):
	        self.x -=4
	        self.direction = "left" 
	    elif (self.direction == "left"):
	        self.x +=4
	        self.direction = "right"
	    elif (self.direction == "down"):
	        self.y -=4
	        self.direction = "up" 
	    elif (self.direction == "up"):
	        self.y +=4
	        self.direction = "down"

	if player.x+28-room.relativex < self.x:
		self.x -= 2
		self.direction = "left"
	if player.x-28-room.relativex > self.x:
		self.direction = "right"
		self.x += 2	
	if player.y+10-room.relativey < self.y:
		self.direction = "up"
		self.y -= 2
	if player.y-10-room.relativey > self.y:
		self.direction = "down"
		self.y += 2

    def collide(self, room, player):
        # FIX BUG
        #print 'gameobject x=%d y=%d player x=%d y=%d' % (self.x,self.y,player.x-room.relativex,player.y-room.relativey)
	if (player.x-room.relativex > self.x-self.w  and 
	player.x-room.relativex < self.x+self.w+self.w and 
	player.y-room.relativey > self.y-self.h and 
	player.y-room.relativey < self.y + self.h +self.h):
	    #print "collision with Game Object!"
	    return 1 
	else:
	    return 0 ## for game self.talker


    def fight(self,room,player):
        self.fightcounter = 1
        o = player.collidewithenemyweapon(room,self)
        if o:
            player.hitwithenemyweapon(RNG().rollsnakebite())
#!/usr/local/bin/python
# Copyright (C) Johan Ceuppens 2010
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

class Stateimagelibrary:
    def __init__(self):
	self.index = 0
	self.max = 0
	self.list = []
    def addpicture(self, image):
	self.list.append(image)
	self.max += 1

    def drawstatic(self, screen, xx, yy, index):
	if (self.index >= self.max):
            self.index = 0

	screen.blit(self.list[index],(xx,yy)) 

    def draw(self, screen, xx, yy):
	if (self.index >= self.max):
            self.index = 0

	screen.blit(self.list[self.index],(xx,yy)) 
	self.index += 1	

# Copyright (C) Johan Ceuppens 2010 
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


import pygame
from pygame.locals import *
from gameobject import *
from inventory import *

class Taskbar:
    "Taskbar"
    def __init__(self, screen, font, player, player2):
        self.screen = screen	
        self.font = font
        self.player = player
        self.player2 = player2
        self.background = pygame.image.load('./pics/blank.bmp').convert()
        self.background.set_colorkey((0,0,255)) 
        self.pc = pygame.image.load(player.askpicture()).convert()
        self.swordimage = pygame.image.load('./pics/taskbar-defaultsword1-32x32.bmp').convert()
        self.swordimage.set_colorkey((0,0,255)) 
        self.pcimage = pygame.image.load(player.askpicture()).convert()
        self.pcimage.set_colorkey((0,0,0))
        if player2:
            self.pcimage2 = pygame.image.load(player2.askpicture()).convert()
            self.pcimage2.set_colorkey((0,0,0))
        self.highlightimage = pygame.image.load('./pics/highlightpc1.bmp').convert()
        self.highlightimage.set_colorkey((0,0,0))

        self.highlightpc = 0
        
    def drawlife(self):
	for i in range(0,self.player.hitpoints):
		self.screen.blit(self.lifeimage, (10+i*2,10))

    def highlight(self):
        self.highlightpc = 1

    def setswordimage(self, imagefilename,r,g,b):
        self.swordimage = pygame.image.load(imagefilename).convert()
        self.swordimage.set_colorkey((r,g,b)) 

    def draw(self):
        self.screen.blit(self.background, (0, 400))
##        
##        self.screen.blit(self.pc, (10, 300))
        self.screen.blit(self.font.render(self.player.askrace() + ' ' + self.player.askclass(), 6, (255,255,255)), (0,450))
        if self.player2:
            self.screen.blit(self.font.render(self.player2.askrace() + ' ' + self.player2.askclass(), 6, (255,255,255)), (100,450))
###       	self.drawlife()
        if self.highlightpc:
            self.screen.blit(self.highlightimage, (0,480))
        self.screen.blit(self.pcimage, (0, 400))
        if self.player2:
            self.screen.blit(self.pcimage2, (100, 400))

    def openinventory(self,playerflag,font):
        if playerflag == 1:
            return Inventory(font)
        elif playerflag == 2:
            return Inventory(font)
        else:
            return 0
        
    def domouse(self, player, player2):
        pos = pygame.mouse.get_pos()
        posx = pos[0]
        posy = pos[1]
        if posx > 0 and posx < 640 and posy > 400 and posy < 480:
            print 'click on taskbar'
            if posx > 0 and posx < 100:
                return 1
            elif posx > 100 and posx < 200:
                return 2
        return 0
            
    def setdungeonkey1(self):
        self.setswordimage('./pics/dungeonkey1-36x36.bmp',0,0,255)

    def setrubysword(self):
        self.setswordimage('./pics/taskbar-rubysword1-32x32.bmp',0,0,255)

# Copyright (C) Johan Ceuppens 2010
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


import pygame
from pygame.locals import *
from koboldwizard import *
from time import *
from maproom import *
from box import *

class Tilebox:
    "box full o tiles"
    
# example:    self.northwall1 = Tilebox(1,1,60,48,16,1,'./pics/walldungeon1-60x48.bmp')
#               draws 16 times the picture from left to right 1 high
    def __init__(self,x,y,w,h,nx,ny,imagefilename):
        # NOTE : self.w self.h is number of w and h tiles
        self.x = x
        self.y = y
        self.w = w
        self.h = h
        self.nx = nx
        self.ny = ny
        self.image = pygame.image.load(imagefilename).convert()
	self.image.set_colorkey((0,0,255))
        
    def draw(self,screen,relx,rely):
        for j in range(0, self.ny):
            for i in range(0,self.nx):
                screen.blit(self.image,(self.x+self.w*i+relx,self.y+self.h*j+rely))

    # NOTE - player.h for fencepost errors
    def collide(self, room, player):
	if (player.x > self.x-room.relativex  and 
	 player.x < self.x-room.relativex + self.w*self.nx and 
	 player.y - player.h > self.y-room.relativey and 
	 player.y - player.h < self.y-room.relativey + self.h*self.ny):
	    print "collision in Tilebox!"	
	    return 1 
	else:
	    return 0


    def collidewithenemy(self, room, enemy):
	if (enemy.x > self.x  and 
	enemy.x < self.x+self.w*self.nx and 
	enemy.y - enemy.h > self.y and 
	enemy.y - enemy.h < self.y + self.h*self.ny):
	    #print "collision in Tilebox with enemy!"	
	    return 1 
	else:
	    return 0


# Copyright (C) Johan Ceuppens 2010 
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


import pygame
from pygame.locals import *
from gameobject import *

class Toadstool(Gameobject):
    "Box"
    def __init__(self, xx,yy):
        Gameobject.__init__(self,xx,yy)
        self.w = 48
        self.h = 48 
        self.image = pygame.image.load('./pics/toadstool1-48x48.bmp').convert()
        self.image.set_colorkey((0,0,0)) 

    def setimage(self, imagefilename,r,g,b):
        self.image = pygame.image.load(imagefilename).convert()
        self.image.set_colorkey((r,g,b)) 

    def collide(self, room, player):
	if (player.x > self.x+room.relativex  and 
	player.x < self.x+room.relativex+self.w and 
	player.y > self.y+room.relativey and 
	player.y < self.y+room.relativey + self.h):
	    print "collision in toadstool!"	
	    return 2 
	else:
	    return 0

# Copyright (C) Johan Ceuppens 2010 
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


import pygame
from pygame.locals import *
from gameobject import *

class Tree2(Gameobject):
    "Tree 2"
    def __init__(self, xx,yy):
        Gameobject.__init__(self,xx,yy)
        self.w = 92 
        self.h = 92 
        self.image = pygame.image.load('./pics/tree2-150x150.bmp').convert()
        self.image.set_colorkey((0,0,0)) 

# Copyright (C) Johan Ceuppens 2010 
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


import pygame
from pygame.locals import *
from gameobject import *

class Tree(Gameobject):
    "Tree"
    def __init__(self, xx,yy):
        Gameobject.__init__(self,xx,yy)
        self.w = 92 
        self.h = 92 
        self.image = pygame.image.load('./pics/tree1-92x92.bmp').convert()
        self.image.set_colorkey((0,0,0)) 

# Copyright (C) Johan Ceuppens 2010
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


import pygame
from pygame.locals import *
from gameobject import *
from stateimagelibrary import *
import random

class TurtleFlying(Gameobject):
    "TurtleFlying"
    def __init__(self,xx,yy):
	Gameobject.__init__(self, xx, yy)
        self.w = 36
        self.h = 36 
	self.stimlibleft = Stateimagelibrary()	
	self.stimlibright = Stateimagelibrary()	
        image = pygame.image.load('./pics/turtleleft1-36x36.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)	
        image = pygame.image.load('./pics/turtleleft1-36x36.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)	
        image = pygame.image.load('./pics/turtleleft1-36x36.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)	
        image = pygame.image.load('./pics/turtleleft1-36x36.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)	
        image = pygame.image.load('./pics/turtleleft2-36x36.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)	
        image = pygame.image.load('./pics/turtleleft2-36x36.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)	
        image = pygame.image.load('./pics/turtleleft2-36x36.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)	
        image = pygame.image.load('./pics/turtleleft2-36x36.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)	
        image = pygame.image.load('./pics/turtleleft3-36x36.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)	
        image = pygame.image.load('./pics/turtleleft3-36x36.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)	
        image = pygame.image.load('./pics/turtleleft3-36x36.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)	
        image = pygame.image.load('./pics/turtleleft3-36x36.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)	
        image = pygame.image.load('./pics/turtleleft2-36x36.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)	
        image = pygame.image.load('./pics/turtleleft2-36x36.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)	
        image = pygame.image.load('./pics/turtleleft2-36x36.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)	
        image = pygame.image.load('./pics/turtleleft2-36x36.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibleft.addpicture(image)	

        image = pygame.image.load('./pics/turtle1-36x36.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibright.addpicture(image)	
        image = pygame.image.load('./pics/turtle1-36x36.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibright.addpicture(image)	
        image = pygame.image.load('./pics/turtle1-36x36.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibright.addpicture(image)	
        image = pygame.image.load('./pics/turtle1-36x36.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibright.addpicture(image)	
        image = pygame.image.load('./pics/turtle2-36x36.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibright.addpicture(image)	
        image = pygame.image.load('./pics/turtle2-36x36.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibright.addpicture(image)	
        image = pygame.image.load('./pics/turtle2-36x36.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibright.addpicture(image)	
        image = pygame.image.load('./pics/turtle2-36x36.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibright.addpicture(image)	
        image = pygame.image.load('./pics/turtle3-36x36.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibright.addpicture(image)	
        image = pygame.image.load('./pics/turtle3-36x36.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibright.addpicture(image)	
        image = pygame.image.load('./pics/turtle3-36x36.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibright.addpicture(image)	
        image = pygame.image.load('./pics/turtle3-36x36.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibright.addpicture(image)	
        image = pygame.image.load('./pics/turtle2-36x36.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibright.addpicture(image)	
        image = pygame.image.load('./pics/turtle2-36x36.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibright.addpicture(image)	
        image = pygame.image.load('./pics/turtle2-36x36.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibright.addpicture(image)	
        image = pygame.image.load('./pics/turtle2-36x36.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlibright.addpicture(image)	

	self.direction = "left"

    def draw(self, screen, room):
	if (self.direction == "left"):
            self.stimlibleft.draw(screen, self.x+room.relativex,self.y+room.relativey)
	elif (self.direction == "right"):
            self.stimlibright.draw(screen, self.x+room.relativex,self.y+room.relativey)
	    
	     
    def update(self,room):
	if (not self.collideobjectX(room)): 
	    if (self.direction == "left"):
	        self.x +=2
	        self.direction = "right" 
	    elif (self.direction == "right"):
	        self.x -=2
	        self.direction = "left"


	if (self.direction == "left"):
	        self.x -=1 
	elif (self.direction == "right"):
	        self.x +=1

    def collide(self, room, player):
	if (player.x > self.x+room.relativex  and 
	player.x < self.x+room.relativex+self.w and 
	player.y > self.y+room.relativey and 
	player.y < self.y+room.relativey + self.h):
	    print "collision with Dark Knight!"
	    if player.hit():
		return 1 
	    else:
	    	return 2 
	else:
	    return 0

		 

# Copyright (C) Johan Ceuppens 2010
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


import pygame
from pygame.locals import *
from gameobject import *
from stateimagelibrary import *
import random
from time import *

class Venomspit(Gameobject):
    "Venom spit"
    def __init__(self,xx,yy):
	Gameobject.__init__(self, xx, yy)
        self.w = 24
        self.h = 24 
	self.stimlib = Stateimagelibrary()
        image = pygame.image.load('./pics/venomspit-24x24.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlib.addpicture(image)		

	self.direction = "down"

    def draw(self, screen, room):
        self.stimlib.draw(screen, self.x+room.relativex,self.y+room.relativey)
		    
	     
    def update(self,room):
        sleep(.01) # FIX venom spit sleep
        if (self.direction == "down"):
	        self.y +=5
	if self.y > self.SCREENH:
            room.removeobject(self)

    def collide(self, room, player):
	if (player.x > self.x+room.relativex  and 
	player.x < self.x+room.relativex+self.w and 
	player.y > self.y+room.relativey and 
	player.y < self.y+room.relativey + self.h):
	    print "collision with Venom spit!"
	    if player.hit():
		return 1 
	    else:
	    	return 2 
	else:
	    return 0

		 

# Copyright (C) Johan Ceuppens 2010
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


import pygame
from pygame.locals import *
from gameobject import *
from stateimagelibrary import *
import random
from time import *

class VenomspitUp(Gameobject):
    "Venom spit"
    def __init__(self,xx,yy):
	Gameobject.__init__(self, xx, yy)
        self.w = 24
        self.h = 24 
	self.stimlib = Stateimagelibrary()
        image = pygame.image.load('./pics/venomspitup-24x24.bmp').convert()
        image.set_colorkey((0,0,0)) 
	self.stimlib.addpicture(image)		

	self.direction = "up"

    def draw(self, screen, room):
        self.stimlib.draw(screen, self.x+room.relativex,self.y+room.relativey)
		    
	     
    def update(self,room):
        sleep(.01) # FIX venom spit sleep
        if (self.direction == "up"):
	        self.y -=5
	if self.y > self.SCREENH:
            room.removeobject(self)

    def collide(self, room, player):
	if (player.x > self.x+room.relativex  and 
	player.x < self.x+room.relativex+self.w and 
	player.y > self.y+room.relativey and 
	player.y < self.y+room.relativey + self.h):
	    print "collision with Venom spit!"
	    if player.hit():
		return 1 
	    else:
	    	return 2 
	else:
	    return 0

		 

# Copyright (C) Johan Ceuppens 2010
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


import pygame
from pygame.locals import *
from gameobject import *
from stateimagelibrary import *
import random
from time import *

class YuanInnKeeper(Gameobject):
    ""
    def __init__(self,xx,yy):
	Gameobject.__init__(self, xx, yy)
        self.w = 48
        self.h = 48 
        self.image = pygame.image.load('./pics/yuaninnkeeper1-48x48.bmp').convert()
        self.image.set_colorkey((0,0,255)) 
        self.talkcounter = 0
        
    def draw(self, screen, room):
        screen.blit(self.image, (self.x+room.relativex,self.y+room.relativey))
	    
	     
    def update(self,room):
        1

    def collide(self, room, player):
	if (player.x > self.x+room.relativex  and 
	player.x < self.x+room.relativex+self.w and 
	player.y > self.y+room.relativey and 
	player.y < self.y+room.relativey + self.h):
	    print "collision with Yuan Inn Keeper!"
	    return 2 
	else:
	    return 0
		 
    def talk(self, screen,font):
        if self.talkcounter == 0:
            return
        
        if self.talkcounter > 2:
                self.talkcounter = 0
                return 
        talkover = 0
        while talkover == 0:
            pygame.display.update()
            if self.talkcounter == 1:
                screen.blit(font.render("Welcome stranger.", 6, (255,255,255)), (10,100))
            elif self.talkcounter == 2:
                screen.blit(font.render("I am Yuan, Fighter-Cleric at your servive.", 6, (255,255,255)), (10,100))
            for event in pygame.event.get():
                if event.type == QUIT:
                    return
                elif event.type == KEYDOWN:
                    if event.key == K_z:
                        talkover = 1
                        self.talkcounter += 1
\end{verbatim}
\end{mylisting}


\section{\large Conclusion}


\bibliographystyle{plain}
\bibliography{refs} % refs.bib

\end{document}

                
